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
import devtool from './devtool';
import module from './module';
import optimization from './optimization';
import plugins from './plugins';
import resolve from './resolve';

export {
devtool,
module,
optimization,
plugins,
resolve
};
File: webpack/configuration/index.js
  1. Add the nodes to webpack.config.babel.js:
  import {
devtool,
module,
optimization,
plugins,
resolve
} from './webpack/configuration';

export default {
devtool,
module,
plugins,
optimization,
resolve
};
File: webpack.config.babel.js
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset