New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

unplugin-compression

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin-compression

Compress dist to `zip`, `tar`, `taz`.

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source
logo of vite-plugin-patch-env repository

unplugin-compression

Compress dist to zip, tar, taz. Powered by unplugin.

English | 简体中文

Installation

pnpm i -D unplugin-compression

Usage

Vite
// vite.config.ts
import Compression from "unplugin-compression/vite";

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


Rollup
// rollup.config.js
import Compression from "unplugin-compression/rollup";

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


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require("unplugin-compression/webpack")({
      /* options */
    }),
  ],
};


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


esbuild
// esbuild.config.js
import { build } from "esbuild";

build({
  /* ... */
  plugins: [
    require("unplugin-compression/esbuild")({
      /* options */
    }),
  ],
});


Configuration

Compression({
  // you can use `zip`, `tar`, `taz`
  adapter: "zip",
  // relative paths to the directory to compress
  source: "dist",
  // relative paths to the directory to output
  outDir: "./",
  // compressed file name
  formatter: "{{name}}.{{ext}}",
});

adapter

Global adapter. When the source does not set the adapter, the global adapter is used.

see compressing

source

The compress source, which can be set as string or Source or Source[]

If you use Source and set adapter or outDir or formatter options, it's cover global options.

Compression({
  source: [
    {
      // zip adapter, dist.zip
      source: "dist",
    },
    {
      // tar adapter, output.tar
      source: "output",
      adapter: "tar",
    },
  ],
});

outDir

The compressed file output dir.

formatter

The compressed filename formatter. default value is {{name}}.{{ext}}.

interface template extends Omit<Source, "formatter"> {
  name: string;
  ext: string;
}

you can also set a handler

Compression({
  formatter(source) {
    return `Hello.${source.adapter}`;
  },
});

compressingOptions

the compressing package opts. see compressing

Compression({
  compressingOptions: {
    ignoreBase: true,
  },
});

Keywords

unplugin

FAQs

Package last updated on 24 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts