diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js
index 7a1b66803bc..dca4378e187 100644
--- a/config/webpack.config.dev.js
+++ b/config/webpack.config.dev.js
@@ -31,21 +31,6 @@ const publicUrl = '';
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);
-// Options for PostCSS as we reference these options twice
-// Adds vendor prefixing based on your specified browser support in
-// package.json
-const postCSSLoaderOptions = {
- // Necessary for external CSS imports to work
- // https://github.com/facebook/create-react-app/issues/2677
- ident: 'postcss',
- plugins: () => [
- require('postcss-flexbugs-fixes'),
- autoprefixer({
- flexbox: 'no-2009',
- }),
- ],
-};
-
// style files regexes
const cssRegex = /\.css$/;
const cssModuleRegex = /\.module\.css$/;
@@ -61,8 +46,21 @@ const getStyleLoaders = (cssOptions, preProcessor) => {
options: cssOptions,
},
{
+ // Options for PostCSS as we reference these options twice
+ // Adds vendor prefixing based on your specified browser support in
+ // package.json
loader: require.resolve('postcss-loader'),
- options: postCSSLoaderOptions,
+ options: {
+ // Necessary for external CSS imports to work
+ // https://github.com/facebook/create-react-app/issues/2677
+ ident: 'postcss',
+ plugins: () => [
+ require('postcss-flexbugs-fixes'),
+ autoprefixer({
+ flexbox: 'no-2009',
+ }),
+ ],
+ },
},
];
if (preProcessor) {
@@ -75,6 +73,7 @@ const getStyleLoaders = (cssOptions, preProcessor) => {
// It is focused on developer experience and fast rebuilds.
// The production configuration is different and lives in a separate file.
module.exports = {
+ mode: 'development',
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
// See the discussion in https://github.com/facebook/create-react-app/issues/343.
devtool: 'cheap-module-source-map',
@@ -116,6 +115,18 @@ module.exports = {
devtoolModuleFilenameTemplate: info =>
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
},
+ optimization: {
+ // Automatically split vendor and commons
+ // https://twitter.com/wSokra/status/969633336732905474
+ // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
+ splitChunks: {
+ chunks: 'all',
+ name: 'vendors',
+ },
+ // Keep the runtime chunk seperated to enable long term caching
+ // https://twitter.com/wSokra/status/969679223278505985
+ runtimeChunk: true,
+ },
resolve: {
// This allows you to set a fallback for where Webpack should look for modules.
// We placed these paths second because we want `node_modules` to "win"
@@ -335,18 +346,16 @@ module.exports = {
],
},
plugins: [
- // Makes some environment variables available in index.html.
- // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
- //
- // In development, this will be an empty string.
- new InterpolateHtmlPlugin(env.raw),
// Generates an `index.html` file with the