mix.scripts 不工作 (webpack.mix.js)

mix.scripts is not working (webpack.mix.js)

我有以下 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

我遇到了同样的问题,你应该尝试使用 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

好吧,这个话题可能有点老了,但我一直在寻找自己的解决方案,所以:

npm update laravel-mix 

npm install cross-env

对我有用。

我解决了问题 使用

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