Skip to content

Zip your build files with JSZip, filtered by your rules, powered by unplugin

License

Notifications You must be signed in to change notification settings

iamspark1e/unplugin-zip-pack

Repository files navigation

unplugin-zip-pack


Zip your build files with JSZip, powered by unplugin

使用JSZip打包构建成果,由unplugin驱动


Quick Start

npm i unplugin-zip-pack@latest -D # Or yarn/pnpm as you like

Configuration

export type Options = {
  /**
   * Input Dir
   * @default `./dist`
   */
  in?: string;
  /**
   * Output file name (with path)
   * @default `dist.zip`
   */
  out?: string;
  filter?: FilterFunction;
  /**
   * Switcher of enable plugin
   * @default true
   */
  enabled?: boolean;
  /**
   * Hook functions run pre/post compress. (if `enabled` is set to false, hooks won't run.)
   */
  hooks?: {
    pre?: Promise;
    post?: Promise;
  }
}

Usage

Vite
// vite.config.ts
import ZipPack from 'unplugin-zip-pack/vite'

export default defineConfig({
  plugins: [
    ZipPack({ /* options */ }),
  ],
})


Rollup
// rollup.config.js
import ZipPack from 'unplugin-zip-pack/rollup'

export default {
  plugins: [
    ZipPack({ /* options */ }),
  ],
}


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-zip-pack/webpack')({ /* options */ })
  ]
}


Nuxt
// nuxt.config.js
export default {
  buildModules: [
    ['unplugin-zip-pack/nuxt', { /* options */ }],
  ],
}

This module works for both Nuxt 2 and Nuxt Vite


Vue CLI
// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-zip-pack/webpack')({ /* options */ }),
    ],
  },
}


esbuild
// esbuild.config.js
import { build } from 'esbuild'
import ZipPack from 'unplugin-zip-pack/esbuild'

build({
  plugins: [ZipPack()],
})