unplugin-compress
v0.1.3
Published
A common compress plugin for Vite/Webpack/Rollup(etc...) powered by Unplugin
Downloads
2
Maintainers
Readme
unplugin-compress
A universal compress plugin for Webpack / Vite / Rollup, powered by Unplugin, generating compressed file using gzip / brotli / etc...
Usage
See more usage example in folder
/examples
. Feel free to modify and play it on your own!
Webpack
// webpack.config.js
const compress = require('unplugin-compress/webpack');
module.exports = ({
mode: 'production',
entry: './src/index.js',
output: {
path: distPath,
},
plugins: [
compress({
filter: /\.js$/,
}),
compress({
filter: /main\.js$/,
algorithm: 'brotliCompress',
extname: '.br',
}),
// etc...
]
});
Vite
// in vite.config.ts
import { defineConfig } from 'vite';
import compress from 'unplugin-compress/vite';
export default defineConfig({
plugins: [
compress({
filter: /\.js$/,
}),
compress({
filter: /\.(js|css)$/,
algorithm: 'brotliCompress',
extname: '.br',
}),
]
});
Rollup
// in rollup.config.js
import compress from 'unplugin-compress/rollup';
export default {
// ...
plugins: [
compress({
filter: /\.js$/,
})
],
// ...
};
Inspiration
Todo
- [x] Vite support.
- [x] Webpack(both 4 and 5) support.
- [x] Rollup support.