0.1.3 • Published 3 years ago

unplugin-compress v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

unplugin-compress

NPM version

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
```js
// 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

  • Vite support.
  • Webpack(both 4 and 5) support.
  • Rollup support.
0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago