diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index e67f04c1e09..f725cb20ee5 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -79,14 +79,14 @@ module.exports = function(webpackEnv) { // common function to get style loaders const getStyleLoaders = (cssOptions, preProcessor) => { const loaders = [ - isEnvDevelopment && require.resolve('style-loader'), - isEnvProduction && { + { loader: MiniCssExtractPlugin.loader, - // css is located in `static/css`, use '../../' to locate index.html folder - // in production `paths.publicUrlOrPath` can be a relative path - options: paths.publicUrlOrPath.startsWith('.') - ? { publicPath: '../../' } - : {}, + options: { + hmr: isEnvDevelopment, + // css is located in `static/css`, use '../../' to locate index.html folder + // in production `paths.publicUrlOrPath` can be a relative path + publicPath: paths.publicUrlOrPath.startsWith('.') ? '../../' : undefined, + }, }, { loader: require.resolve('css-loader'), @@ -485,10 +485,7 @@ module.exports = function(webpackEnv) { }, // "postcss" loader applies autoprefixer to our CSS. // "css" loader resolves paths in CSS and adds assets as dependencies. - // "style" loader turns CSS into JS modules that inject