Skip to content

Commit

Permalink
Only enable HMR when --watch specified
Browse files Browse the repository at this point in the history
  • Loading branch information
lbmaian committed Dec 1, 2021
1 parent f55e0fd commit 1704fb2
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = (env, options) => {

const envVersion = env.version;
const hasEnvVersion = (envVersion != null && typeof envVersion === 'string');
const watch = env.WEBPACK_WATCH;

const cssConfig = {
test: /\.(sa|sc|c)ss$/,
Expand Down Expand Up @@ -87,7 +88,7 @@ module.exports = (env, options) => {
dev: !prod // Built-in HMR
},
emitCss: false,
hotReload: !prod,
hotReload: !prod && watch,
preprocess
}
}
Expand Down Expand Up @@ -142,16 +143,18 @@ module.exports = (env, options) => {
config.devtool = false;
} else {
config.devtool = 'eval-cheap-module-source-map';
config.plugins.push(new webpack.HotModuleReplacementPlugin(), extReloader);
// config.devServer = {
// host: 'localhost',
// port: 6000,
// hot: true,
// contentBase: path.join(__dirname, 'build'),
// headers: { 'Access-Control-Allow-Origin': '*' },
// writeToDisk: true,
// disableHostCheck: true
// };
if (watch) {
config.plugins.push(new webpack.HotModuleReplacementPlugin(), extReloader);
// config.devServer = {
// host: 'localhost',
// port: 6000,
// hot: true,
// contentBase: path.join(__dirname, 'build'),
// headers: { 'Access-Control-Allow-Origin': '*' },
// writeToDisk: true,
// disableHostCheck: true
// };
}
}

return config;
Expand Down

0 comments on commit 1704fb2

Please sign in to comment.