How to do it...

Let's add a source map to our Webpack:

  1. 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
  1. 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
  1. Remember that you need to add those new files into index.js:
 // Configuration ...

Get React Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.