Skip to content

Commit 56fd0c1

Browse files
authored
feat: configure MiniCssExtractPlugin for production environment in webpack (#1897)
2 parents ae80b92 + c7b615d commit 56fd0c1

File tree

3 files changed

+140
-2
lines changed

3 files changed

+140
-2
lines changed

package-lock.json

Lines changed: 130 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"license": "AGPL-3.0",
1616
"main": "app.js",
1717
"scripts": {
18-
"build": "webpack --config webpack.prod.js --display errors-only -p",
18+
"build": "cross-env NODE_ENV=production webpack --config webpack.prod.js --display errors-only -p",
1919
"dev": "webpack --config webpack.dev.js --progress --colors --watch",
2020
"doctoc": "doctoc --title='# Table of Contents' README.md",
2121
"lint": "standard",
@@ -120,6 +120,7 @@
120120
"bootstrap": "~3.4.0",
121121
"bootstrap-validator": "~0.11.8",
122122
"copy-webpack-plugin": "~4.5.2",
123+
"cross-env": "^7.0.3",
123124
"css-loader": "~1.0.0",
124125
"dictionary-de": "^2.0.3",
125126
"dictionary-de-at": "^2.0.3",

webpack.common.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,14 @@ module.exports = {
202202
to: 'fork-awesome/css'
203203
}
204204
]),
205-
new MiniCssExtractPlugin()
205+
new MiniCssExtractPlugin(
206+
process.env.NODE_ENV === 'production'
207+
? {
208+
filename: '[name].[contenthash].css',
209+
chunkFilename: '[name].[contenthash].css',
210+
}
211+
: {},
212+
)
206213
],
207214

208215
entry: {

0 commit comments

Comments
 (0)