Now, we will configure webpack for hot reloading. We start by splitting our webpack.config.js into two files:
- webpack.config.prod.js: The production build, the content will mostly be copied over from our current config file
- webpack.config.dev.js: The development build, which enables hot reloading
We are now going to create those two files:
- Rename the current webpack.config.js to webpack.config.prod.js, then edit package.json, specifying the new config file in the build:webpack script:
"build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
- While we are at it, let's also modify the start:dev script to use the webpack.config.dev.js config:
"start:dev": "webpack-dev-server ...