ITellMyselfSecrets's avatar

Running mix for multiple javascript files

I want to compile multiple JS files using Laravel Mix and also make them generate as separated files. Right now they are all combined and I want them separated. This is my mix file

mix.js(['resources/assets/js/admin.js', 'resources/assets/js/frontend.js'], 'public/js')
    .sass('resources/assets/sass/app.scss', 'public/css');

Thanks

0 likes
5 replies
bobbybouwmann's avatar
Level 88

You can run multiple .js calls on the mix variable. That way they will be generated separately.

mix.js('resources/assets/js/admin.js', 'public/js')
    .js('resources/assets/js/frontend.js', 'public/js')
    .sass('resources/assets/sass/app.scss', 'public/css');

Let me know if that works for you!

3 likes
timo.heil's avatar

But how to extract admin and frotned libraries to different vendor files? I wouldn't want to load the admin lbraries in the frontend...

1 like
jamalali's avatar

@timo.heil Have you found a solution for this? (i.e to extract admin and frontend libraries to different vendor files)

FabLPA's avatar

Hi all, Same kind of bugs here. Have you found any solutions or tricks for this ?

When I build the assets separatly (run JS / run SCSS) I get correct files, but when both run together, CSS files are empty.

Get last version of laravel-mix (5.0.1), wepack (4.42.0) (and pretty much all packages' last versions).

I have import in SCSS files, and load dynamic vue-js component in JS files.

Any idea ?

Please or to participate in this conversation.