Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack - [HMR] and [WDS] firing twice

Tags:

I'm getting messages like [HMR] Waiting for update signal from WDS... and [WDS] Hot Module Replacement enabled. twice in Dev Tools console. Why is that? Am I doing something wrong?

Console screenshot

My webpack.config.js file:

...  module.exports = () => {      return {          entry: {              bundle: './src/app/App.jsx',              sw: './src/app/sw.js'          },          output: {              filename: '[name].js',              path: path.resolve(__dirname, 'dist'),              globalObject: 'this'          },          devtool: 'source-map',          devServer: {              contentBase: path.resolve(__dirname, 'dist'),              historyApiFallback: true          },  ...          node: {              fs: 'empty',              net: 'empty',              tls: 'empty'          }      };  };

Versions: "webpack": "^4.27.1", "react-hot-loader": "^4.6.0", "webpack-dev-server": "^3.1.10"

like image 496
Jan Chalupa Avatar asked Jan 06 '19 23:01

Jan Chalupa


People also ask

What is HMR Webpack?

Hot Module Replacement (or HMR) is one of the most useful features offered by webpack. It allows all kinds of modules to be updated at runtime without the need for a full refresh. This page focuses on implementation while the concepts page gives more details on how it works and why it's useful.

What is hotmodulereplacementplugin?

Enables Hot Module Replacement, otherwise known as HMR.

Does Webpack increase performance?

Webpack provides support for caching the build files generated to improve the build speed. We can achieve this by providing a cache option set to true in the webpack. config. js file.

What does Webpack mode production do?

In production mode, Webpack does everything to use the bundle for production. It includes minification of the bundle file and other optimizations. Default value of mode is production .


1 Answers

I resolved this by removing the the auto injection line in public/index.html:

    <div id="app"></div> <!-- built files will be auto injected --> <!-- <script type="text/javascript" src="/js/chunk-vendors.js"></script><script type="text/javascript" src="/js/app.js"></script> --> 

Previously I was building vue site and using a nodejs express server to serve it statically. When I changed to using 'vue-cli-service serve' exclusivly I encountered this issue.

I hope this information is helpful to someone.

like image 85
John Waring Avatar answered Sep 25 '22 18:09

John Waring