Let's add a source map to our Webpack:
- Create the webpack/configuration/devtool.js file:
const isProduction = process.env.NODE_ENV === 'production'; export default !isProduction ? 'cheap-module-source-map' : 'eval';
File: webpack/configuration/devtool.js
- Split the bundles (using the new "optimization" Webpack node): one for our /node_modules/ which will be the biggest one, and one for our React Application. You need to create the optimization.js file and add this code:
export default { splitChunks: { cacheGroups: { default: false, commons: { test: /node_modules/, name: 'vendor', chunks: 'all' } } } }
File: webpack/configuration/optimization.js
- Remember that you need to add those new files into index.js:
// Configuration ...