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 12, 2022
1 parent d8e6470 commit 0e166df
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 4 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 @@ -99,6 +100,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 @@ -99,6 +101,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": "^6.7.1",
"css-minimizer-webpack-plugin": "^4.1.0",
"electron": "^20.1.2",
"electron-builder": "^23.3.3",
"electron-debug": "^3.2.0",
Expand All @@ -105,6 +106,7 @@
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-vue": "^7.17.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 0e166df

Please sign in to comment.