diff options
author | Vitaly Takmazov | 2023-09-11 09:29:12 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-09-11 09:38:20 +0300 |
commit | a907348d931510fea77546e8748a1fcf2c73ea0a (patch) | |
tree | 7ac4f6991dcb66e2e4298d8951e78fb3b056a553 /vnext | |
parent | 1872c44992091df97dfd1a53053044a2264f5dc6 (diff) |
Minimize CSS in production builds
Diffstat (limited to 'vnext')
-rw-r--r-- | vnext/webpack.config.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/vnext/webpack.config.js b/vnext/webpack.config.js index 810a63bd..0ce5d9a4 100644 --- a/vnext/webpack.config.js +++ b/vnext/webpack.config.js @@ -1,13 +1,12 @@ const ESLintPlugin = require('eslint-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin') +const CssMinimizerPlugin = require('css-minimizer-webpack-plugin') const TerserPlugin = require('terser-webpack-plugin') -module.exports = () => { - const node_env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development' - const dev = node_env !== 'production' +module.exports = (env, argv) => { + const dev = argv.mode !== 'production' const config = { - mode: node_env, devtool: dev ? 'source-map' : false, entry: { 'index': [ @@ -90,6 +89,12 @@ module.exports = () => { overlay: true } } + } else { + config.plugins.push( + new MiniCssExtractPlugin({ + filename: 'Juick.[contenthash].css' + }) + ) } config.optimization = { minimize: !dev, @@ -100,6 +105,7 @@ module.exports = () => { // Link to options - https://swc.rs/docs/config-js-minify terserOptions: {}, }), + new CssMinimizerPlugin() ] } return config |