0

我想将我所有的脚本合并到一个缩小的 javascript 文件中,但是我在合并它们时遇到了麻烦。

mix.browserify([
  // ViewModels
  'viewmodels.js'
], 'resources/assets/compiled/js/viewmodels.js')

mix.coffee([
  // WebSocket Client
  'client.coffee'
], 'resources/assets/compiled/js/').scripts([
  // Vendor
  'vendor/jquery.js',
  'vendor/bootstrap.js',
  'vendor/vue.js',
  'vendor/sisyphus.js',
  'vendor/leaflet.js',
  'vendor/moment.min.js'
], 'resources/assets/compiled/js/vendor.js').scripts([
  // Site & Helpers
  'libs/laravel.js',
  'libs/helpers.js'
], 'resources/assets/compiled/js/site.js').scripts([
  // Combine Scripts
  'resources/assets/compiled/js/vendor.js',
  'resources/assets/compiled/js/client.js',
  'resources/assets/compiled/js/site.js',
  'resources/assets/compiled/js/viewmodels.js'
], 'public/js/all.js', './')

这些文件是在 中创建的resources/assets/compiled/js,所以我有:

  • 客户端.js
  • 网站.js
  • 供应商.js
  • 视图模型.js

运行的最后一个任务是scripts组合这四个文件的任务。长生不老药日志状态(我简化了输出):

  • 浏览器化(视图模型)
  • CoffeeScript 编译
  • 合并供应商
  • 合并站点和助手
  • 合并组合脚本

...这些是我收到的错误消息:

File not found: ./resources/assets/compiled/js/vendor.js
File not found: ./resources/assets/compiled/js/site.js

sass我用and做了同样的事情,styles而且效果很好。

mix.sass([
  // Vendor
  'resources/assets/sass/fontawesome/font-awesome.scss',
  // Site
  'resources/assets/sass/site/site.scss'
], 'resources/assets/compiled/css/').styles([
  // Vendor
  'resources/assets/css/bootstrap.min.css',
  'resources/assets/css/hover-min.css',
  'resources/assets/css/leaflet.css',
  'resources/assets/compiled/css/font-awesome.css',
  // Site
  'resources/assets/compiled/css/site.css'
], 'public/css/all.css', './').version(
  'public/css/all.css'
)
4

1 回答 1

0

为什么不一次合并脚本而不是合并 3 次?

像这样试试

mix.coffee([
  // WebSocket Client
  'client.coffee'
], 'resources/assets/compiled/js/')
  .scripts([
    // Vendor
    'resources/assets/js/vendor/jquery.js',
    'resources/assets/js/vendor/bootstrap.js',
    'resources/assets/js/vendor/vue.js',
    'resources/assets/js/vendor/sisyphus.js',
    'resources/assets/js/vendor/leaflet.js',
    'resources/assets/js/vendor/moment.min.js',
    // Site & Helpers
    'resources/assets/js/libs/laravel.js',
    'resources/assets/js/libs/helpers.js',
    'resources/assets/compiled/js/client.js',
    'resources/assets/compiled/js/viewmodels.js'
  ], 'public/js/all.js', './');
于 2015-07-22T10:49:21.827 回答