compression-webpack-plugin

  • Version 11.1.0
  • Published
  • 37.1 kB
  • 2 dependencies
  • MIT license

Install

npm i compression-webpack-plugin
yarn add compression-webpack-plugin
pnpm add compression-webpack-plugin

Overview

Prepare compressed versions of assets to serve them with Content-Encoding

Index

Classes

class CompressionPlugin

class CompressionPlugin<T = import('zlib').ZlibOptions>
implements WebpackPluginInstance {}
  • [T=ZlibOptions] WebpackPluginInstance

constructor

constructor(
options?: BasePluginOptions<T> &
(
| {
algorithm?: string | AlgorithmFunction<T>;
compressionOptions?: InferDefaultType<T>;
}
| {
algorithm: string | AlgorithmFunction<T>;
compressionOptions?: InferDefaultType<T>;
}
)
);
  • Parameter options

method apply

apply: (compiler: any) => void;
  • Parameter compiler

    Returns

    {void}

Type Aliases

type AlgorithmFunction

type AlgorithmFunction<T> = (
input: Buffer,
options: CompressionOptions<T>,
callback: (
error: Error | null | undefined,
result:
| string
| ArrayBuffer
| SharedArrayBuffer
| Uint8Array
| readonly number[]
| {
valueOf(): ArrayBuffer | SharedArrayBuffer;
}
| {
valueOf(): string | Uint8Array | readonly number[];
}
| {
valueOf(): string;
}
| {
[Symbol.toPrimitive](hint: 'string'): string;
}
) => void
) => any;

    type Asset

    type Asset = import('webpack').Asset;

      type BasePluginOptions

      type BasePluginOptions<T> = {
      test?: Rules | undefined;
      include?: Rules | undefined;
      exclude?: Rules | undefined;
      threshold?: number | undefined;
      minRatio?: number | undefined;
      deleteOriginalAssets?: DeleteOriginalAssets | undefined;
      filename?: Filename | undefined;
      };

        type Compilation

        type Compilation = import('webpack').Compilation;

          type Compiler

          type Compiler = import('webpack').Compiler;

            type CompressionOptions

            type CompressionOptions<T> = InferDefaultType<T>;

              type CustomOptions

              type CustomOptions = {
              [key: string]: any;
              };

                type DefinedDefaultAlgorithmAndOptions

                type DefinedDefaultAlgorithmAndOptions<T> = T extends ZlibOptions
                ? {
                algorithm?: string | AlgorithmFunction<T> | undefined;
                compressionOptions?: CompressionOptions<T> | undefined;
                }
                : {
                algorithm: string | AlgorithmFunction<T>;
                compressionOptions?: CompressionOptions<T> | undefined;
                };

                  type DeleteOriginalAssets

                  type DeleteOriginalAssets =
                  | boolean
                  | 'keep-source-map'
                  | ((name: string) => boolean);

                    type Filename

                    type Filename = string | ((fileData: PathData) => string);

                      type InferDefaultType

                      type InferDefaultType<T> = T extends infer U ? U : CustomOptions;

                        type InternalPluginOptions

                        type InternalPluginOptions<T> = BasePluginOptions<T> & {
                        algorithm: string | AlgorithmFunction<T>;
                        compressionOptions: CompressionOptions<T>;
                        threshold: number;
                        minRatio: number;
                        deleteOriginalAssets: DeleteOriginalAssets;
                        filename: Filename;
                        };

                          type PathData

                          type PathData = {
                          [key: string]: any;
                          };

                            type Rule

                            type Rule = RegExp | string;

                              type Rules

                              type Rules = Rule[] | Rule;

                                type Schema

                                type Schema = import('schema-utils/declarations/validate').Schema;

                                  type Source

                                  type Source = import('webpack').sources.Source;

                                    type WebpackError

                                    type WebpackError = import('webpack').WebpackError;

                                      type WebpackPluginInstance

                                      type WebpackPluginInstance = import('webpack').WebpackPluginInstance;

                                        type WithImplicitCoercion

                                        type WithImplicitCoercion<T> =
                                        | T
                                        | {
                                        valueOf(): T;
                                        };

                                          type ZlibOptions

                                          type ZlibOptions = import('zlib').ZlibOptions;

                                            Package Files (1)

                                            Dependencies (2)

                                            Dev Dependencies (29)

                                            Peer Dependencies (1)

                                            Badge

                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/compression-webpack-plugin.

                                            • Markdown
                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/compression-webpack-plugin)
                                            • HTML
                                              <a href="https://www.jsdocs.io/package/compression-webpack-plugin"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>