Reputation: 770
We run some of our javascript files through the babel()
functionality that Laravel mix supplies to have some backwards compatibility.
The problem we have is that if we change anything in the app.js or app.scss the watch script gets triggerd and Laravel mix automaticly compiles the correct scripts, but it does not trigger on any changes in any of the files that we feed into babel()
. It does not matter if we run watch
or watch-poll
. It does compile the babel()
scripts if we rerun watch manually, or if we run production/dev.
I have tried to find documentation on babel()
or watch
that explains this strange behavior. but could not find anything that explains this weird issue.
webpack.mix.js
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
// Compile some resources independently to not include it in all pages.
.babel('resources/assets/js/cart.js', 'public/js/cart.js')
.babel('resources/assets/js/manage-addresses.js', 'public/js/manage-addresses.js')
.babel('resources/assets/js/catalog-overview-order.js', 'public/js/catalog-overview-order.js');
package.json
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
Software versions:
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"@fortawesome/fontawesome-free": "^5.5.0",
"axios": "^0.17",
"bootstrap": "^4.1.3",
"cross-env": "^5.1",
"datatables": "^1.10.18",
"datatables.net-bs4": "^1.10.19",
"datatables.net-buttons-bs4": "^1.5.3",
"datatables.net-plugins": "^1.10.18",
"datatables.net-rowreorder": "^1.2.5",
"datatables.net-rowreorder-bs4": "^1.2.5",
"jquery": "^3.2",
"laravel-mix": "^4.0.14",
"popper.js": "^1.14.6",
"resolve-url-loader": "^2.3.1",
"sass": "^1.16.1",
"sass-loader": "^7.1.0",
"vue-template-compiler": "^2.5.22"
},
"dependencies": {
"@babel/polyfill": "^7.2.5",
"animate.css": "^3.7.0",
"bootstrap4-notify": "^4.0.3",
"dropzone": "^5.5.1",
"jquery-mask-plugin": "^1.14.15",
"select2": "^4.0.5",
"toastr": "^2.1.4"
}
}
Upvotes: 3
Views: 1801
Reputation: 1973
You should have mix.js() with some inputs piped into babel.
mix.js('resources/assets/js/cart.js', 'public/js/cart.js').babel('public/js/cart.js', 'public/js/cart.js')
Upvotes: 3