0.0.1 • Published 4 years ago
@dking/compress-webpack-plugin v0.0.1
Webpack Compress Plugin
Tips: Personal learning to write webpack plug-ins, not recommended for production environment
Webpack-Compress-Plugin support
gzip
andbrotli
compress.
Install
$ npm i @dking/webpack-compress-plugin --dev
$ yarn add @dking/webpack-compress-plugin -D
Usage
// webpack.config.js
const path = require('path');
const CompressPlugin = require('@dking/compress-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new CompressPlugin({
deleteOriginalAssets: true,
algorithm : 'brotli',
})
]
};
Configuration
new CompressPlugin({
deleteOriginalAssets: false, // Whether to delete the files before compression depends on the situation. The default setting is false
algorithm : 'gzip', // Compression algorithm, the default is gzip
test : /./, // All files are compressed by default
threshold : 1000, // Only resources larger than this value are processed. In bytes
minRatio : 0.8, // Only resources with a compression ratio lower than this value will be processed
})
Questions
Please open an issue here.
License
0.0.1
4 years ago