Using Laravel Mix, is it possible to watch two Webpack config files with one command so that changes to any of the underlying files instantly cause the necessary files to be compiled?
Specifically, I have the following two Webpack config files I'm using with Laravel Mix: webpack.css.mix.js
and webpack.js.mix.js
I then have the following commands in the scripts
object of package.json
:
"development-css": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --watch --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.css.mix",
"development-js": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --watch --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.js.mix",
"watch": "npm run development-css -- --watch & npm run development-js -- --watch",
The npm run watch
command only watches the first command specified though. In the above case, any changes I save to the Sass files will build, but no changes to any JS/Vue files. If I switch the two commands in the watch
command, then the JS will build on change/save, but not the Sass.
Does anyone have any ideas how to structure the npm run watch
command (or the underlying commands), so that I can watch both the Sass and JS at the same time?
Also, for what it's worth, due to a bug in Laravel Mix at the moment, I had to separate the Sass and JS compilation into two separate files. This bug is documented here: https://github.com/JeffreyWay/laravel-mix/issues/1914
The discussion does solve the bug, but not how to combine the two commands into one watch command. Thank you.