https://github.com/johnapache/compress-webpack-plugin
webpack 压缩插件 支持 gzip brotli
https://github.com/johnapache/compress-webpack-plugin
brotli-compress gzip-compress webpack webpack-compress webpack-compress-plugin webpack-plugin
Last synced: about 1 month ago
JSON representation
webpack 压缩插件 支持 gzip brotli
- Host: GitHub
- URL: https://github.com/johnapache/compress-webpack-plugin
- Owner: JohnApache
- License: mit
- Created: 2020-08-04T08:06:12.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-04T08:49:46.000Z (almost 6 years ago)
- Last Synced: 2025-07-30T18:38:03.727Z (11 months ago)
- Topics: brotli-compress, gzip-compress, webpack, webpack-compress, webpack-compress-plugin, webpack-plugin
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.en_US.md
- License: LICENSE
Awesome Lists containing this project
README
# Webpack Compress Plugin
> Tips: Personal learning to write webpack plug-ins, not recommended for production environment
- [English](README.en_US.md)
- [简体中文](README.md)
> Webpack-Compress-Plugin support `gzip` and `brotli` compress.
- [Install](#install)
- [Usage](#usage)
- [Configuration](#configuration)
- [Questions](#questions)
- [License](#license)
## Install
```bash
$ npm i @dking/webpack-compress-plugin --dev
$ yarn add @dking/webpack-compress-plugin -D
```
## Usage
```js
// 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
```js
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](https://github.com/webpack-contrib/compression-webpack-plugin/issues).
## License
[MIT](LICENSE)