When running yarn run hot I get the following error. I have verified permissions on the public directory being 0755 since this is a local development environment. It appears that the HMR is _not_ compiling those assets and pushing them into place as that file indeed does not exist.
$ yarn run hot
yarn run v1.0.1
$ 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
DONE Compiled successfully in 7567ms 11:40:12 AM
fs.js:652
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/Users/andrew/Developer/GitHub/CallLoop/TextLoop/public/js/vendor.js'
at Object.fs.openSync (fs.js:652:18)
at Object.fs.readFileSync (fs.js:553:33)
at File.read (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/File.js:180:19)
at File.version (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/File.js:190:25)
at Manifest.hash (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/Manifest.js:55:65)
at manifest.forEach.file (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:79:47)
at Array.forEach (<anonymous>)
at CustomTasksPlugin.applyVersioning (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:79:18)
at Compiler.compiler.plugin.stats (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:12:22)
at Compiler.applyPlugins (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/tapable/lib/Tapable.js:61:14)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
My webpack.mix.js contains:
let mix = require('laravel-mix');
if (process.env.NODE_ENV === 'production') {
mix.disableNotifications();
}
mix.webpackConfig({
devtool: 'source-map'
})
.autoload({
jquery: ['$', 'window.jQuery', 'jQuery', 'jquery'],
'popper.js/dist/umd/popper.js': ['Popper']
})
.js('resources/assets/js/app.js', 'public/js')
.extract([
// Bootstrap/jQuery
'jquery',
'jquery.payment',
'jquery.phone',
'popper.js',
'bootstrap',
// Vendors
'axios',
'babel-polyfill',
'es6-promise',
'lodash',
'moment',
'moment-timezone',
// Vue
'vue',
'vuex',
'vue-router',
])
.sass('resources/assets/sass/app.scss', 'public/css')
.version();
This appears to be caused by the mix.version() at the end. If I add NODE_HOT=true to the hot command in package.json. Then change mix.version() to the following HMR works.
if (!process.env.NODE_HOT) {
mix.version();
}
Is there a native way to detect if running in HMR so I don't have to add the extra ENVVAR?
Thank you for this, worked a charm.
// Version does not work in HMR mode
if (process.env.npm_lifecycle_event !== 'hot') {
mix.version()
}
Most helpful comment