The code below throwed an error
ENOENT: no such file or directory, open 'F:\test\laravel54\public\assets\js\*.js'
mix
.js('resources/assets/js/**/*.js', 'public/assets/js')
.less('resources/assets/less/**/*.less', 'public/assets/css')
.version()
It might be a design decision to not add more scope to the library. That being said, you have access to the glob package and can achieve the above with something like this:
const glob = require('glob');
let jsFiles = glob.sync('resources/assets/js/**/*.js');
let lessFiles = glob.sync(('resources/assets/less/**/*.less');
// If combining to one entry file
mix
.js(jsFiles, 'public/assets/js')
.less(lessFiles, 'public/assets/css')
.version()
// If each file is its own entry file
jsFiles.forEach(filename => {
mix.js(filename, 'public/assets/js);
});
lessFiles.forEach(filename => {
mix.less(filename, 'public/assets/css);
});
Also see some discussion in Webpack's own threads: https://github.com/webpack/webpack/issues/370
I've added glob support for JS compilation, but not yet CSS.
Hey, I've writted a package to do this kind of thing :
https://www.npmjs.com/package/webpack-entry-watcher
Thanks for integrating glob support, however, the current implementation compiles everything into one file. In order to compile them separately there's still manual work required, just as https://github.com/JeffreyWay/laravel-mix/issues/1419#issuecomment-358677059 describes.
Most helpful comment
It might be a design decision to not add more scope to the library. That being said, you have access to the
globpackage and can achieve the above with something like this:Also see some discussion in Webpack's own threads: https://github.com/webpack/webpack/issues/370