twg_'s avatar
Level 6

Mix specific files based on flag

I was wondering if I could use a single webpack.mix.js file to mix all of my files for each sub section of my website. I have all fo the files living inside a global project but I would like to only mix certain ones when I need to without having to wait for them all to mix each time.

0 likes
2 replies
RyanPurcella's avatar

Shouldn't be a problem. Just tell mix where you want to put them.

const mix = require('laravel-mix');

// 1. A single src and output path.
mix.js('src/app.js', 'dist/app.js');

// 2. For additional src files that should be
// bundled together:
mix.js([
    'src/app.js',
    'src/another.js'
], 'dist/app.js');

// 3. For multiple entry/output points:
mix.js('src/app.js', 'dist/')
   .js('src/forum.js', 'dist/');
1 like
RyanPurcella's avatar

I guess you could read your question two ways. If you want to have multiple (separate) mix files and run them independently, check out this repo. It might be a valid approach for what you need depending on how many sections you have to your site.

https://github.com/omnichronous/multimix

Please or to participate in this conversation.