From bed16c7e298f6957e7817e05cf3c339e369e766c Mon Sep 17 00:00:00 2001 From: atanasster Date: Sun, 7 Mar 2021 10:19:39 -0500 Subject: [PATCH] fix: style loader --- core/webpack-configs/package.json | 1 - core/webpack-configs/src/react/index.ts | 23 +++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/core/webpack-configs/package.json b/core/webpack-configs/package.json index c0453381e..a162814f0 100644 --- a/core/webpack-configs/package.json +++ b/core/webpack-configs/package.json @@ -49,7 +49,6 @@ "raw-loader": "^4.0.2", "sass": "^1.32.8", "sass-loader": "^11.0.1", - "style-loader": "^2.0.0", "typescript": "^4.0.5", "url-loader": "^4.1.1", "webpack": "^5.24.3" diff --git a/core/webpack-configs/src/react/index.ts b/core/webpack-configs/src/react/index.ts index 84b63f964..ba4b7debe 100644 --- a/core/webpack-configs/src/react/index.ts +++ b/core/webpack-configs/src/react/index.ts @@ -28,13 +28,15 @@ export const react: PresetCallback = (options: BuildProps) => { }, }); } - const result: Configuration = { + const result = { plugins: [ new MiniCssExtractPlugin({ filename: options.cssFileName || defCssFileName, }), - ], - optimization: { minimizer: [] }, + ].filter(Boolean), + optimization: { + minimizer: [isProd && new CssMinimizerPlugin()].filter(Boolean), + }, performance: { hints: false }, module: { rules: [ @@ -134,9 +136,11 @@ export const react: PresetCallback = (options: BuildProps) => { // Creates `style` nodes from JS strings { loader: MiniCssExtractPlugin.loader, - options: customLoaderOptions(options, 'mini-css-extract-plugin', { - publicPath: '', - }), + options: customLoaderOptions( + options, + 'mini-css-extract-plugin', + {}, + ), }, { // Translates CSS into CommonJS @@ -202,11 +206,6 @@ export const react: PresetCallback = (options: BuildProps) => { resolve: { extensions: ['.ts', '.tsx', '.js', '.jsx'], }, - }; - if (isProd) { - result.optimization = { - minimizer: [new CssMinimizerPlugin()], - }; - } + } as Configuration; return result; };