compression-webpack-plugin

  • Version 12.0.0
  • Published
  • 40.9 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

    options

method apply

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

    compiler

    Returns

    {void}

Type Aliases

type AlgorithmFunction

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

    type Asset

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

      type AssetInfo

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

        type BasePluginOptions

        type BasePluginOptions<T> = {
        /**
        * include all assets that pass test assertion
        */
        test?: Rules | undefined;
        /**
        * include all assets matching any of these conditions
        */
        include?: Rules | undefined;
        /**
        * exclude all assets matching any of these conditions
        */
        exclude?: Rules | undefined;
        /**
        * only assets bigger than this size are processed, in bytes
        */
        threshold?: number | undefined;
        /**
        * only assets that compress better than this ratio are processed (`minRatio = Compressed Size / Original Size`)
        */
        minRatio?: number | undefined;
        /**
        * whether to delete the original assets or not
        */
        deleteOriginalAssets?: DeleteOriginalAssets | undefined;
        /**
        * the target asset filename
        */
        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]: EXPECTED_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 EXPECTED_ANY

                      type EXPECTED_ANY = any;

                        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 = import('webpack').PathData;

                                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 (27)

                                                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>