在laravel 5中缩小js和样式

时间:2018-01-31 23:46:46

标签: laravel minify laravel-mix

如何将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文件中,但它会创建空文件。

1 个答案:

答案 0 :(得分:1)

您必须从Laravel应用程序的根目录使用完整路径启动

所以而不是:

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

正如您所说,theme位于public之下,您应该这样做:

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

网址的其余部分进行此更新