Using multiple webpack methods on laravel elixir

433 views Asked by At

I'm using Laravel 5.3 and Elixir:

"laravel-elixir": "^6.0.0-9",
"laravel-elixir-rollup-official": "^1.0.5",
"laravel-elixir-vue": "^0.1.4",
"laravel-elixir-webpack-official": "^1.0.2",

I'm using multiple wepback methods in my gulpfile.js file, as you can see here:

elixir(mix => {
    mix
        .copy('node_modules/font-awesome/fonts', 'public/build/fonts')
        .sass('client.scss', 'public/css/client.css')
        .sass('panel.scss', 'public/css/panel.css')
        // .webpack('app.js')
        .webpack('panel.js')
        .version(['css/client.css', 'css/panel.css', 'js/app.js', 'js/panel.js']);
});

I've noticed that (sometimes) when I use multiple webpack methods, and run gulp watch, I get this error:

stream.js:74
  throw er; // Unhandled stream error in pipe.
  ^

Error: ENOENT: no such file or directory, stat '...\build\js\app-6ced943929.js'
at Error (native)

Is it wrong to use multiple times with the method webpack? Is there an alternative way to separate 2 different js files?

1

There are 1 answers

0
Ohgodwhy On

Not 100% sure regarding this particular case, but you can just invoke a new stream for this and you should be able to avoid the issue:

mix.webpack('app.js');

mix.webpack('panel.js');

Of course your .version() would then need to be added to each stream separately so there is the introduction of a bit of code redundancy.