Skip to content

Commit a69cbd3

Browse files
authored
Optimise CSS and JSON files (#2569)
1 parent 426b71f commit a69cbd3

File tree

5 files changed

+426
-4
lines changed

5 files changed

+426
-4
lines changed

_scripts/webpack.main.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const path = require('path')
22
const webpack = require('webpack')
33
const CopyWebpackPlugin = require('copy-webpack-plugin')
4+
const JsonMinimizerPlugin = require('json-minimizer-webpack-plugin')
45

56
const { productName } = require('../package.json')
67

@@ -30,6 +31,13 @@ const config = {
3031
},
3132
],
3233
},
34+
// webpack defaults to only optimising the production builds, so having this here is fine
35+
optimization: {
36+
minimizer: [
37+
'...', // extend webpack's list instead of overwriting it
38+
new JsonMinimizerPlugin()
39+
]
40+
},
3341
node: {
3442
__dirname: isDevMode,
3543
__filename: isDevMode,

_scripts/webpack.renderer.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const webpack = require('webpack')
33
const HtmlWebpackPlugin = require('html-webpack-plugin')
44
const VueLoaderPlugin = require('vue-loader/lib/plugin')
55
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
6+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
67

78
const { productName } = require('../package.json')
89

@@ -99,6 +100,13 @@ const config = {
99100
},
100101
],
101102
},
103+
// webpack defaults to only optimising the production builds, so having this here is fine
104+
optimization: {
105+
minimizer: [
106+
'...', // extend webpack's list instead of overwriting it
107+
new CssMinimizerPlugin()
108+
]
109+
},
102110
node: {
103111
__dirname: isDevMode,
104112
__filename: isDevMode,

_scripts/webpack.web.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
44
const VueLoaderPlugin = require('vue-loader/lib/plugin')
55
const CopyWebpackPlugin = require('copy-webpack-plugin')
66
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
7+
const JsonMinimizerPlugin = require('json-minimizer-webpack-plugin')
8+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
79

810
const { productName } = require('../package.json')
911

@@ -99,6 +101,14 @@ const config = {
99101
},
100102
],
101103
},
104+
// webpack defaults to only optimising the production builds, so having this here is fine
105+
optimization: {
106+
minimizer: [
107+
'...', // extend webpack's list instead of overwriting it
108+
new JsonMinimizerPlugin(),
109+
new CssMinimizerPlugin()
110+
]
111+
},
102112
node: {
103113
__dirname: isDevMode,
104114
__filename: isDevMode,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"babel-loader": "^8.2.5",
9393
"copy-webpack-plugin": "^11.0.0",
9494
"css-loader": "^6.7.1",
95+
"css-minimizer-webpack-plugin": "^4.1.0",
9596
"electron": "^20.1.2",
9697
"electron-builder": "^23.3.3",
9798
"electron-debug": "^3.2.0",
@@ -105,6 +106,7 @@
105106
"eslint-plugin-standard": "^5.0.0",
106107
"eslint-plugin-vue": "^7.17.0",
107108
"html-webpack-plugin": "^5.3.2",
109+
"json-minimizer-webpack-plugin": "^4.0.0",
108110
"mini-css-extract-plugin": "^2.2.2",
109111
"node-loader": "^2.0.0",
110112
"npm-run-all": "^4.1.5",

0 commit comments

Comments
 (0)