Skip to content

Commit 4fcec6d

Browse files
committed
fix: re-add minification
1 parent f379212 commit 4fcec6d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

config/webpack.config.prod.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
1111
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
1212
const paths = require('../config/paths');
1313
const getClientEnvironment = require('./env');
14+
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
15+
const safePostCssParser = require('postcss-safe-parser');
1416

1517
// Webpack uses `publicPath` to determine where the app is being served from.
1618
// It requires a trailing slash, or the file assets will get an incorrect path.
@@ -107,6 +109,20 @@ module.exports = {
107109
// Enable file caching
108110
cache: true,
109111
sourceMap: shouldUseSourceMap
112+
}),
113+
new OptimizeCSSAssetsPlugin({
114+
cssProcesorOptions: {
115+
parser: safePostCssParser,
116+
map: shouldUseSourceMap
117+
? {
118+
// This forces the sourcemap to be output into a separate file
119+
inline: false,
120+
// This appends the sourceMappingURL to the end of the css file,
121+
// helping the browser find the sourcemap
122+
annotation: true
123+
}
124+
: false
125+
}
110126
})
111127
],
112128
// Automatically split vendor and commons

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"http-proxy-middleware": "^0.20.0",
4545
"mini-css-extract-plugin": "^0.4.0",
4646
"minimist": "1.2.0",
47+
"optimize-css-assets-webpack-plugin": "^5.0.3",
4748
"postcss-flexbugs-fixes": "^3.3.0",
4849
"postcss-loader": "2.1.5",
4950
"promise": "8.0.1",

0 commit comments

Comments
 (0)