Currently in our gulpfile.js
we have every single JS file being .scripts()
'ed.
We want to transfer from each single file, to a more logical one. Using something like a foreach loop that loops through all javascript files within a given directory, copy them to public/js
then minify them with any plugin, and .version()
them so they're in a build folder.
How can you foreach all those files and what would be a logical step to minify + version the files?
To concatenate and minify, do this
// first arg is an array of files, relative to /resources/assets/js/
// second arg is the destination
mix.scripts([
'/../bower/jquery/dist/jquery.min.js',
'/myfile.js',
],
'public/js/deps.js');
Although minification will only occur when you run gulp --production
.
To version your assets, use the elixir()
helper in your views. It's in the docs .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.