Last active
May 15, 2023 21:13
-
-
Save yekowele/5467c87e3048f873cb15487498f6d23f to your computer and use it in GitHub Desktop.
Laravel Webpack Mix - Mix all files separately in directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mix = require('laravel-mix'); | |
let fs = require('fs'); | |
let getFiles = function (dir) { | |
// get all 'files' in this directory | |
// filter directories | |
return fs.readdirSync(dir).filter(file => { | |
return fs.statSync(`${dir}/${file}`).isFile(); | |
}); | |
}; | |
getFiles('resources/js').forEach(function (JSpath) { | |
if(JSpath !== 'global.js' || JSpath !== 'app.js' ){ //Do not mix 'global.js' and 'app.js' | |
mix.js('resources/js/' + JSpath, 'public/js'); | |
} | |
}); | |
getFiles('resources/sass').forEach(function (SASSpath) { | |
if(SASSpath.charAt(0) !== '_'){ // Do not mix which files start with '_' (underscore) | |
mix.sass('resources/sass/' + SASSpath, 'public/css'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment