From c8be008e52af620d868fb68930bb63fb5a820eea Mon Sep 17 00:00:00 2001 From: Joshua Kiwiet-Pantaleoni Date: Fri, 15 Sep 2023 12:52:35 -0700 Subject: [PATCH] fix: ensure icons are compressed and skip font compression MARS-288 --- build/webpack.base.conf.js | 15 --------------- build/webpack.client.base.conf.js | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 94a04d9fe1..340bdd39df 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -5,7 +5,6 @@ const VueLoaderPlugin = require('vue-loader').VueLoaderPlugin; const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const FilterWarningsPlugin = require('webpack-filter-warnings-plugin'); const webpack = require('webpack'); -const CompressionPlugin = require('compression-webpack-plugin'); const GitRevisionPlugin = require('git-revision-webpack-plugin'); const HardSourceWebpackPlugin = require('hard-source-webpack-plugin-fixed-hashbug'); const gitRevisionPlugin = new GitRevisionPlugin({ @@ -332,19 +331,5 @@ module.exports = { sizeThreshold: 500 * 1024 * 1024 } })]), - ...(isProd ? [ - // gzip compression - new CompressionPlugin({ - // Compress all assets for upload - minRatio: Infinity, - }), - // brotli compression - new CompressionPlugin({ - filename: "[path][base].br", - algorithm: "brotliCompress", - // Compress all assets for upload - minRatio: Infinity, - }), - ] : []), ] }; diff --git a/build/webpack.client.base.conf.js b/build/webpack.client.base.conf.js index bf508194d2..4b63af05a9 100644 --- a/build/webpack.client.base.conf.js +++ b/build/webpack.client.base.conf.js @@ -1,12 +1,20 @@ const { merge } = require('webpack-merge'); var assetsPath = require('./assets-path'); var baseWebpackConfig = require('./webpack.base.conf'); +var CompressionPlugin = require('compression-webpack-plugin'); var SvgStorePlugin = require('webpack-svgstore-plugin'); var VueSSRClientPlugin = require('vue-server-renderer/client-plugin'); const HardSourceWebpackPlugin = require('hard-source-webpack-plugin-fixed-hashbug') const isProd = process.env.NODE_ENV === 'production'; +const compressionOptions = { + // Compress all assets for upload + minRatio: Infinity, + // Ignore fonts because they are already compressed + exclude: /\.woff|\.woff2|\.ttf|\.eot/, +}; + module.exports = merge(baseWebpackConfig, { entry: { app: './src/client-entry.js' @@ -34,6 +42,19 @@ module.exports = merge(baseWebpackConfig, { }, prefix: 'icon-', }), + // file compression + ...(isProd ? [ + // gzip compression + new CompressionPlugin({ + ...compressionOptions, + }), + // brotli compression + new CompressionPlugin({ + ...compressionOptions, + filename: "[path][base].br", + algorithm: "brotliCompress", + }), + ] : []), ...(isProd ? [] : [new HardSourceWebpackPlugin.ExcludeModulePlugin([ // Due to how some loaders emit assets, certain assets are not emitted // on repeated builds with those loaders and hard-source together.