mix.scripts不起作用(webpack.mix.js)

时间:2017-03-03 09:22:21

标签: javascript node.js laravel laravel-5 laravel-mix

我有以下webpack.mix.js:

const { mix } = require('laravel-mix');
mix.scripts([
    'resources/assets/js/app.js',
    'resources/assets/js/definers.js',
    'resources/assets/js/tab_system.js',
    'resources/assets/js/searchbox.js',
    'node_modules/angular/angular.js',
], 'public/js/app.js', 'public/js');

mix.js('resources/assets/js/afegir_caracteristica_visuals.js', 'public/js')
    .js('resources/assets/js/afegir_categoria_visuals.js', 'public/js')
    .js('resources/assets/js/afegir_localitat_visuals.js', 'public/js')
    .js('resources/assets/js/afegir_tipo_visuals.js', 'public/js')
    .js('resources/assets/js/afegir_transaccio_visuals.js', 'public/js')
    .js('resources/assets/js/eliminar_element.js', 'public/js');

mix.styles([
    'resources/assets/css/tab_system.css',
    'resources/assets/sass/app.scss',
], 'public/css/app.css');

当我运行npm run dev时,我收到此错误: error in the cmd with the homestead ssh

3 个答案:

答案 0 :(得分:2)

这个话题可能有点老了,但是我自己寻找解决方案,所以:

npm update laravel-mix 

npm install cross-env

为我工作。

答案 1 :(得分:0)

我有同样的问题,你应该尝试使用mix.combine而不是mix.scripts。 所以脚本的第一部分应该成为:

mix.combine([
    'resources/assets/js/app.js',
    'resources/assets/js/definers.js',
    'resources/assets/js/tab_system.js',
    'resources/assets/js/searchbox.js',
    'node_modules/angular/angular.js',
], 'public/js/app.js', 'public/js');

我在这里找到了解决方案:https://github.com/JeffreyWay/laravel-mix/blob/master/docs/concatenation-and-minification.md

答案 2 :(得分:0)

我解决了问题 使用

mix.js('resources/js/app.js', 'public/js')