Skip to content

Commit

Permalink
Optimise CSS and JSON files
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue committed Sep 11, 2022
1 parent 1d0f2a7 commit cc5f07a
Show file tree
Hide file tree
Showing 5 changed files with 436 additions and 5 deletions.
8 changes: 8 additions & 0 deletions _scripts/webpack.main.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path')
const webpack = require('webpack')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const JsonMinimizerPlugin = require('json-minimizer-webpack-plugin')

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

Expand Down Expand Up @@ -30,6 +31,13 @@ const config = {
},
],
},
// webpack defaults to only optimising the production builds, so having this here is fine
optimization: {
minimizer: [
'...', // extend webpack's list instead of overwriting it
new JsonMinimizerPlugin()
]
},
node: {
__dirname: isDevMode,
__filename: isDevMode,
Expand Down
8 changes: 8 additions & 0 deletions _scripts/webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')

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

Expand Down Expand Up @@ -97,6 +98,13 @@ const config = {
},
],
},
// webpack defaults to only optimising the production builds, so having this here is fine
optimization: {
minimizer: [
'...', // extend webpack's list instead of overwriting it
new CssMinimizerPlugin()
]
},
node: {
__dirname: isDevMode,
__filename: isDevMode,
Expand Down
10 changes: 10 additions & 0 deletions _scripts/webpack.web.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const JsonMinimizerPlugin = require('json-minimizer-webpack-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')

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

Expand Down Expand Up @@ -97,6 +99,14 @@ const config = {
},
],
},
// webpack defaults to only optimising the production builds, so having this here is fine
optimization: {
minimizer: [
'...', // extend webpack's list instead of overwriting it
new JsonMinimizerPlugin(),
new CssMinimizerPlugin()
]
},
node: {
__dirname: isDevMode,
__filename: isDevMode,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"babel-loader": "^8.2.5",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "5.2.6",
"css-minimizer-webpack-plugin": "^4.1.0",
"electron": "^20.1.2",
"electron-builder": "^23.3.3",
"electron-builder-squirrel-windows": "^23.5.0",
Expand All @@ -107,6 +108,7 @@
"eslint-plugin-vue": "^7.17.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.2",
"json-minimizer-webpack-plugin": "^4.0.0",
"mini-css-extract-plugin": "^2.2.2",
"node-loader": "^2.0.0",
"npm-run-all": "^4.1.5",
Expand Down
Loading

0 comments on commit cc5f07a

Please sign in to comment.