在 laravel 5 中缩小 js 和样式

minify js and styles in laravel 5

如何将我的 JavaScript 和 css 文件合并到一个文件中?

目前我有:

let mix = require('laravel-mix');

mix.styles([
  'theme/admin/assets/css/bootstrap.css',
  'theme/admin/assets/font-awesome/css/font-awesome.css',
  'theme/admin/assets/css/zabuto_calendar.css',
  'theme/admin/assets/lineicons/style.css',
  'theme/admin/assets/css/style.css',
  'theme/admin/assets/css/style-responsive.css',
  'css/adminstyle.css'
], 'public/css/admin.css');

mix.scripts([
  'theme/admin/assets/js/jquery.min.js',
  'theme/admin/assets/js/bootstrap.min.js',
  'theme/admin/assets/js/jquery.dcjqaccordion.2.7.js',
  'theme/admin/assets/js/jquery.scrollTo.min.js',
  'theme/admin/assets/js/jquery.nicescroll.js',
  'theme/admin/assets/js/jquery.sparkline.js',
  'theme/admin/assets/js/common-scripts.js',
  'theme/admin/assets/js/zabuto_calendar.js'
], 'public/js/admin.js');

在我的 webpack.mix.js 文件中,但它创建了空文件。

您必须使用从 Laravel 应用程序的根目录开始 的完整路径。

所以代替:

'theme/admin/assets/css/bootstrap.css'

正如您所说 themepublic 之下,您应该这样做:

'public/theme/admin/assets/css/bootstrap.css'

URLs

的其余部分执行此更新