terser-webpack-plugin

  • Version 5.3.11
  • Published
  • 88 kB
  • 5 dependencies
  • MIT license

Install

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

Overview

Terser plugin for webpack

Index

Functions

function esbuildMinify

esbuildMinify: typeof esbuildMinify;
  • Parameter input

    Parameter sourceMap

    Parameter minimizerOptions

    {Promise}

function swcMinify

swcMinify: typeof swcMinify;
  • Parameter input

    Parameter sourceMap

    Parameter minimizerOptions

    {Promise}

function terserMinify

terserMinify: typeof terserMinify;
  • Parameter input

    Parameter sourceMap

    Parameter minimizerOptions

    Parameter extractComments

    {Promise}

function uglifyJsMinify

uglifyJsMinify: typeof uglifyJsMinify;
  • Parameter input

    Parameter sourceMap

    Parameter minimizerOptions

    Parameter extractComments

    {Promise}

Classes

class TerserPlugin

class TerserPlugin<T = import('terser').MinifyOptions> {}
  • [T=TerserOptions]

constructor

constructor(
options?: BasePluginOptions &
(
| {
minify?: MinimizerImplementation<T>;
terserOptions?: MinimizerOptions<T>;
}
| {
minify: MinimizerImplementation<T>;
terserOptions?: MinimizerOptions<T>;
}
)
);
  • Parameter options

method apply

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

    Returns

    {void}

Type Aliases

type Asset

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

    type BasePluginOptions

    type BasePluginOptions = {
    test?: Rules | undefined;
    include?: Rules | undefined;
    exclude?: Rules | undefined;
    extractComments?: ExtractCommentsOptions | undefined;
    parallel?: Parallel;
    };

      type BasicMinimizerImplementation

      type BasicMinimizerImplementation<T> = (
      input: Input,
      sourceMap: SourceMapInput | undefined,
      minifyOptions: MinimizerOptions<T>,
      extractComments: ExtractCommentsOptions | undefined
      ) => Promise<MinimizedResult>;

        type Compilation

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

          type Compiler

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

            type CustomOptions

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

              type DefinedDefaultMinimizerAndOptions

              type DefinedDefaultMinimizerAndOptions<T> = T extends TerserOptions
              ? {
              minify?: MinimizerImplementation<T> | undefined;
              terserOptions?: MinimizerOptions<T> | undefined;
              }
              : {
              minify: MinimizerImplementation<T>;
              terserOptions?: MinimizerOptions<T> | undefined;
              };

                type ExtractCommentsBanner

                type ExtractCommentsBanner = string | boolean | ((commentsFile: string) => string);

                  type ExtractCommentsCondition

                  type ExtractCommentsCondition =
                  | boolean
                  | 'all'
                  | 'some'
                  | RegExp
                  | ExtractCommentsFunction;

                    type ExtractCommentsFilename

                    type ExtractCommentsFilename = string | ((fileData: any) => string);

                      type ExtractCommentsFunction

                      type ExtractCommentsFunction = (
                      astNode: any,
                      comment: {
                      value: string;
                      type: 'comment1' | 'comment2' | 'comment3' | 'comment4';
                      pos: number;
                      line: number;
                      col: number;
                      }
                      ) => boolean;

                        type ExtractCommentsObject

                        type ExtractCommentsObject = {
                        condition?: ExtractCommentsCondition | undefined;
                        filename?: ExtractCommentsFilename | undefined;
                        banner?: ExtractCommentsBanner | undefined;
                        };

                          type ExtractCommentsOptions

                          type ExtractCommentsOptions = ExtractCommentsCondition | ExtractCommentsObject;

                            type InferDefaultType

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

                              type Input

                              type Input = {
                              [file: string]: string;
                              };

                                type InternalOptions

                                type InternalOptions<T> = {
                                name: string;
                                input: string;
                                inputSourceMap: SourceMapInput | undefined;
                                extractComments: ExtractCommentsOptions | undefined;
                                minimizer: {
                                implementation: MinimizerImplementation<T>;
                                options: MinimizerOptions<T>;
                                };
                                };

                                  type InternalPluginOptions

                                  type InternalPluginOptions<T> = BasePluginOptions & {
                                  minimizer: {
                                  implementation: MinimizerImplementation<T>;
                                  options: MinimizerOptions<T>;
                                  };
                                  };

                                    type JestWorker

                                    type JestWorker = import('jest-worker').Worker;

                                      type MinimizedResult

                                      type MinimizedResult = {
                                      code: string;
                                      map?: import('@jridgewell/trace-mapping').SourceMapInput | undefined;
                                      errors?: (string | Error)[] | undefined;
                                      warnings?: (string | Error)[] | undefined;
                                      extractedComments?: string[] | undefined;
                                      };

                                        type MinimizeFunctionHelpers

                                        type MinimizeFunctionHelpers = {
                                        getMinimizerVersion?: (() => string | undefined) | undefined;
                                        };

                                          type MinimizerImplementation

                                          type MinimizerImplementation<T> = BasicMinimizerImplementation<T> &
                                          MinimizeFunctionHelpers;

                                            type MinimizerOptions

                                            type MinimizerOptions<T> = PredefinedOptions & InferDefaultType<T>;

                                              type MinimizerWorker

                                              type MinimizerWorker<T> = import('jest-worker').Worker & {
                                              transform: (options: string) => MinimizedResult;
                                              minify: (options: InternalOptions<T>) => MinimizedResult;
                                              };

                                                type Parallel

                                                type Parallel = undefined | boolean | number;

                                                  type PredefinedOptions

                                                  type PredefinedOptions = {
                                                  module?: boolean | undefined;
                                                  ecma?: import('terser').ECMA | undefined;
                                                  };

                                                    type Rule

                                                    type Rule = RegExp | string;

                                                      type Rules

                                                      type Rules = Rule[] | Rule;

                                                        type Schema

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

                                                          type SourceMapInput

                                                          type SourceMapInput = import('@jridgewell/trace-mapping').SourceMapInput;

                                                            type TerserECMA

                                                            type TerserECMA = import('./utils.js').TerserECMA;

                                                              type TerserOptions

                                                              type TerserOptions = import('./utils.js').TerserOptions;

                                                                type TraceMap

                                                                type TraceMap = import('@jridgewell/trace-mapping').TraceMap;

                                                                  type WebpackError

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

                                                                    Namespaces

                                                                    namespace esbuildMinify

                                                                    namespace esbuildMinify {}

                                                                      function getMinimizerVersion

                                                                      getMinimizerVersion: () => string | undefined;
                                                                      • Returns

                                                                        {string | undefined}

                                                                      namespace swcMinify

                                                                      namespace swcMinify {}

                                                                        function getMinimizerVersion

                                                                        getMinimizerVersion: () => string | undefined;
                                                                        • Returns

                                                                          {string | undefined}

                                                                        namespace terserMinify

                                                                        namespace terserMinify {}

                                                                          function getMinimizerVersion

                                                                          getMinimizerVersion: () => string | undefined;
                                                                          • Returns

                                                                            {string | undefined}

                                                                          namespace uglifyJsMinify

                                                                          namespace uglifyJsMinify {}

                                                                            function getMinimizerVersion

                                                                            getMinimizerVersion: () => string | undefined;
                                                                            • Returns

                                                                              {string | undefined}

                                                                            Package Files (2)

                                                                            Dependencies (5)

                                                                            Dev Dependencies (33)

                                                                            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/terser-webpack-plugin.

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