'Specify the order of scripts in Laravel Mix
I'm trying to combine two JS scripts into one file. One is a third-party library, and the other is some custom js. No matter how I specify the scripts in the mix.js array, it always puts the custom.js on top. I want to put the library on top. How can I achieve that?
Method 1
mix.js([
'node_modules/zoid/dist/zoid.frameworks.frame.min.js',
'public/js/custom.js'
], 'public/js/combined.js').version();
Method 2
mix.js([
'public/js/custom.js',
'node_modules/zoid/dist/zoid.frameworks.frame.min.js'
], 'public/js/combined.js').version();
Solution 1:[1]
Consider the following Mix configuration file.
mix.combine(['one.js', 'two.js'], 'merged.js');
This instructs Mix to merge - or concatenate - one.js and two.js into a single file, called merged.js. As always, during development, that merged file will remain uncompressed. However, when building for production, merged.js will, of course, be minified.
Also, mix.scripts()
is an alias for mix.combine()
; you can use either or.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |