Skip to content

Commit

Permalink
fix: ensure icons are compressed and skip font compression MARS-288
Browse files Browse the repository at this point in the history
  • Loading branch information
emuvente committed Sep 19, 2023
1 parent 9bd843d commit 40bfcf6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
15 changes: 0 additions & 15 deletions build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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,
}),
] : []),
]
};
21 changes: 21 additions & 0 deletions build/webpack.client.base.conf.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 40bfcf6

Please sign in to comment.