 \href{https://github.com/webpack/webpack}{\texttt{  }} 

\href{https://npmjs.com/package/terser-webpack-plugin}{\texttt{ }} \href{https://nodejs.org}{\texttt{ }} \href{https://david-dm.org/webpack-contrib/terser-webpack-plugin}{\texttt{ }} \href{https://github.com/webpack-contrib/terser-webpack-plugin/actions}{\texttt{ }} \href{https://codecov.io/gh/webpack-contrib/terser-webpack-plugin}{\texttt{ }} \href{https://gitter.im/webpack/webpack}{\texttt{ }} \href{https://packagephobia.now.sh/result?p=terser-webpack-plugin}{\texttt{ }}\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30346}{}\doxysection{terser-\/webpack-\/plugin}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30346}
This plugin uses \href{https://github.com/terser-js/terser}{\texttt{ terser}} to minify your Java\+Script.\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30347}{}\doxysubsection{Getting Started}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30347}
To begin, you\textquotesingle{}ll need to install {\ttfamily terser-\/webpack-\/plugin}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install terser-\/webpack-\/plugin -\/-\/save-\/dev }

\end{DoxyCode}


Then add the plugin to your {\ttfamily webpack} config. For example\+:

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{const TerserPlugin = require('terser-\/webpack-\/plugin');}
\DoxyCodeLine{}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [new TerserPlugin()],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}


And run {\ttfamily webpack} via your preferred method.\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30348}{}\doxysubsection{Options}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30348}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30349}{}\doxysubsubsection{$<$tt$>$test$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30349}
Type\+: {\ttfamily String$\vert$\+Reg\+Exp$\vert$\+Array$<$String$\vert$\+Reg\+Exp$>$} Default\+: {\ttfamily /\textbackslash{}.m?js(\textbackslash{}?.$\ast$)?\$/i}

Test to match files against.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        test: /\(\backslash\).js(\(\backslash\)?.*)?\$/i,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30350}{}\doxysubsubsection{$<$tt$>$include$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30350}
Type\+: {\ttfamily String$\vert$\+Reg\+Exp$\vert$\+Array$<$String$\vert$\+Reg\+Exp$>$} Default\+: {\ttfamily undefined}

Files to include.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        include: /\(\backslash\)/includes/,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30351}{}\doxysubsubsection{$<$tt$>$exclude$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30351}
Type\+: {\ttfamily String$\vert$\+Reg\+Exp$\vert$\+Array$<$String$\vert$\+Reg\+Exp$>$} Default\+: {\ttfamily undefined}

Files to exclude.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        exclude: /\(\backslash\)/excludes/,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30352}{}\doxysubsubsection{$<$tt$>$cache$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30352}
\begin{quote}
⚠ Ignored in webpack 5! Please use \href{https://webpack.js.org/configuration/other-options/\#cache}{\texttt{ https\+://webpack.\+js.\+org/configuration/other-\/options/\#cache}}. \end{quote}
Type\+: {\ttfamily Boolean$\vert$\+String} Default\+: {\ttfamily true}

Enable file caching. Default path to cache directory\+: {\ttfamily node\+\_\+modules/.cache/terser-\/webpack-\/plugin}.

\begin{quote}
ℹ️ If you use your own {\ttfamily minify} function please read the {\ttfamily minify} section for cache invalidation correctly. \end{quote}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30353}{}\doxyparagraph{$<$tt$>$\+Boolean$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30353}
Enable/disable file caching.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        cache: true,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30354}{}\doxyparagraph{$<$tt$>$\+String$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30354}
Enable file caching and set path to cache directory.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        cache: 'path/to/cache',}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30355}{}\doxysubsubsection{$<$tt$>$cache\+Keys$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30355}
\begin{quote}
⚠ Ignored in webpack 5! Please use \href{https://webpack.js.org/configuration/other-options/\#cache}{\texttt{ https\+://webpack.\+js.\+org/configuration/other-\/options/\#cache}}. \end{quote}
Type\+: {\ttfamily Function$<$(default\+Cache\+Keys, file) -\/$>$ Object$>$} Default\+: {\ttfamily default\+Cache\+Keys =$>$ default\+Cache\+Keys}

Allows you to override default cache keys.

Default cache keys\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{(\{}
\DoxyCodeLine{  terser: require('terser/package.json').version, // terser version}
\DoxyCodeLine{  'terser-\/webpack-\/plugin': require('../package.json').version, // plugin version}
\DoxyCodeLine{  'terser-\/webpack-\/plugin-\/options': this.options, // plugin options}
\DoxyCodeLine{  nodeVersion: process.version, // Node.js version}
\DoxyCodeLine{  name: file, // asset path}
\DoxyCodeLine{  contentHash: crypto.createHash('md4').update(input).digest('hex'), // source file hash}
\DoxyCodeLine{\}); }

\end{DoxyCode}


{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        cache: true,}
\DoxyCodeLine{        cacheKeys: (defaultCacheKeys, file) => \{}
\DoxyCodeLine{          defaultCacheKeys.myCacheKey = 'myCacheKeyValue';}
\DoxyCodeLine{}
\DoxyCodeLine{          return defaultCacheKeys;}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30356}{}\doxysubsubsection{$<$tt$>$parallel$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30356}
Type\+: {\ttfamily Boolean$\vert$\+Number} Default\+: {\ttfamily true}

Use multi-\/process parallel running to improve the build speed. Default number of concurrent runs\+: {\ttfamily os.\+cpus().length -\/ 1}.

\begin{quote}
ℹ️ Parallelization can speedup your build significantly and is therefore {\bfseries{highly recommended}}. \end{quote}
\begin{quote}
⚠️ If you use {\bfseries{Circle CI}} or any other environment that doesn\textquotesingle{}t provide real available count of CPUs then you need to setup explicitly number of CPUs to avoid {\ttfamily Error\+: Call retries were exceeded} (see \href{https://github.com/webpack-contrib/terser-webpack-plugin/issues/143}{\texttt{ \#143}}, \href{https://github.com/webpack-contrib/terser-webpack-plugin/issues/202}{\texttt{ \#202}}). \end{quote}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30357}{}\doxyparagraph{$<$tt$>$\+Boolean$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30357}
Enable/disable multi-\/process parallel running.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        parallel: true,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30358}{}\doxyparagraph{$<$tt$>$\+Number$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30358}
Enable multi-\/process parallel running and set number of concurrent runs.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        parallel: 4,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30359}{}\doxysubsubsection{$<$tt$>$source\+Map$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30359}
Type\+: {\ttfamily Boolean} Default\+: {\ttfamily false} (see below for details around {\ttfamily devtool} value and {\ttfamily Source\+Map\+Dev\+Tool\+Plugin} plugin)

$\ast$$\ast$\+Works only with {\ttfamily source-\/map}, {\ttfamily inline-\/source-\/map}, {\ttfamily hidden-\/source-\/map} and {\ttfamily nosources-\/source-\/map} values for the \href{https://webpack.js.org/configuration/devtool/}{\texttt{ {\ttfamily devtool}}} option.$\ast$$\ast$

Why?


\begin{DoxyItemize}
\item {\ttfamily eval} wraps modules in {\ttfamily eval(\char`\"{}string\char`\"{})} and the minimizer does not handle strings.
\item {\ttfamily cheap} has not column information and minimizer generate only a single line, which leave only a single mapping.
\end{DoxyItemize}

The plugin respect the \href{https://webpack.js.org/configuration/devtool/}{\texttt{ {\ttfamily devtool}}} and using the {\ttfamily Source\+Map\+Dev\+Tool\+Plugin} plugin. Using supported {\ttfamily devtool} values enable source map generation. Using {\ttfamily Source\+Map\+Dev\+Tool\+Plugin} with enabled the {\ttfamily columns} option enables source map generation.

Use source maps to map error message locations to modules (this slows down the compilation). If you use your own {\ttfamily minify} function please read the {\ttfamily minify} section for handling source maps correctly.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        sourceMap: true,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30360}{}\doxysubsubsection{$<$tt$>$minify$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30360}
Type\+: {\ttfamily Function} Default\+: {\ttfamily undefined}

Allows you to override default minify function. By default plugin uses \href{https://github.com/terser-js/terser}{\texttt{ terser}} package. Useful for using and testing unpublished versions or forks.

\begin{quote}
⚠️ {\bfseries{Always use {\ttfamily require} inside {\ttfamily minify} function when {\ttfamily parallel} option enabled}}. \end{quote}
{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        // Can be async}
\DoxyCodeLine{        minify: (file, sourceMap) => \{}
\DoxyCodeLine{          const extractedComments = [];}
\DoxyCodeLine{}
\DoxyCodeLine{          // Custom logic for extract comments}
\DoxyCodeLine{}
\DoxyCodeLine{          const \{ map, code \} = require('uglify-\/module') // Or require('./path/to/uglify-\/module')}
\DoxyCodeLine{            .minify(file, \{}
\DoxyCodeLine{              /* Your options for minification */}
\DoxyCodeLine{            \});}
\DoxyCodeLine{}
\DoxyCodeLine{          return \{ map, code, extractedComments \};}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30361}{}\doxysubsubsection{$<$tt$>$terser\+Options$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30361}
Type\+: {\ttfamily Object} Default\+: \href{https://github.com/terser-js/terser\#minify-options}{\texttt{ default}}

Terser minify \href{https://github.com/terser-js/terser\#minify-options}{\texttt{ options}}.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        terserOptions: \{}
\DoxyCodeLine{          ecma: undefined,}
\DoxyCodeLine{          parse: \{\},}
\DoxyCodeLine{          compress: \{\},}
\DoxyCodeLine{          mangle: true, // Note `mangle.properties` is `false` by default.}
\DoxyCodeLine{          module: false,}
\DoxyCodeLine{          output: null,}
\DoxyCodeLine{          toplevel: false,}
\DoxyCodeLine{          nameCache: null,}
\DoxyCodeLine{          ie8: false,}
\DoxyCodeLine{          keep\_classnames: undefined,}
\DoxyCodeLine{          keep\_fnames: false,}
\DoxyCodeLine{          safari10: false,}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30362}{}\doxysubsubsection{$<$tt$>$extract\+Comments$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30362}
Type\+: {\ttfamily Boolean$\vert$\+String$\vert$\+Reg\+Exp$\vert$\+Function$<$(node, comment) -\/$>$ Boolean$\vert$\+Object$>$$\vert$\+Object} Default\+: {\ttfamily true}

Whether comments shall be extracted to a separate file, (see \href{https://github.com/webpack/webpack/commit/71933e979e51c533b432658d5e37917f9e71595a}{\texttt{ details}}). By default extract only comments using {\ttfamily /$^\wedge$\textbackslash{}$\ast$$\ast$!$\vert$@preserve$\vert$@license$\vert$@cc\+\_\+on/i} regexp condition and remove remaining comments. If the original file is named {\ttfamily foo.\+js}, then the comments will be stored to {\ttfamily foo.\+js.\+LICENSE.\+txt}. The {\ttfamily terser\+Options.\+output.\+comments} option specifies whether the comment will be preserved, i.\+e. it is possible to preserve some comments (e.\+g. annotations) while extracting others or even preserving comments that have been extracted.\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30363}{}\doxyparagraph{$<$tt$>$\+Boolean$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30363}
Enable/disable extracting comments.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        extractComments: true,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30364}{}\doxyparagraph{$<$tt$>$\+String$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30364}
Extract {\ttfamily all} or {\ttfamily some} (use {\ttfamily /$^\wedge$\textbackslash{}$\ast$$\ast$!$\vert$@preserve$\vert$@license$\vert$@cc\+\_\+on/i} Reg\+Exp) comments.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        extractComments: 'all',}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30365}{}\doxyparagraph{$<$tt$>$\+Reg\+Exp$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30365}
All comments that match the given expression will be extracted to the separate file.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        extractComments: /@extract/i,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30366}{}\doxyparagraph{$<$tt$>$\+Function$<$(node, comment) -\/$>$ Boolean$>$$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30366}
All comments that match the given expression will be extracted to the separate file.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        extractComments: (astNode, comment) => \{}
\DoxyCodeLine{          if (/@extract/i.test(comment.value)) \{}
\DoxyCodeLine{            return true;}
\DoxyCodeLine{          \}}
\DoxyCodeLine{}
\DoxyCodeLine{          return false;}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30367}{}\doxyparagraph{$<$tt$>$\+Object$<$/tt$>$}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30367}
Allow to customize condition for extract comments, specify extracted file name and banner.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        extractComments: \{}
\DoxyCodeLine{          condition: /\string^\(\backslash\)**!|@preserve|@license|@cc\_on/i,}
\DoxyCodeLine{          filename: (fileData) => \{}
\DoxyCodeLine{            // The "{}fileData"{} argument contains object with "{}filename"{}, "{}basename"{}, "{}query"{} and "{}hash"{}}
\DoxyCodeLine{            return `\$\{fileData.filename\}.LICENSE.txt\$\{fileData.query\}`;}
\DoxyCodeLine{          \},}
\DoxyCodeLine{          banner: (licenseFile) => \{}
\DoxyCodeLine{            return `License information can be found in \$\{licenseFile\}`;}
\DoxyCodeLine{          \},}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}


\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30368}%
\Hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30368}%
\doxysubparagraph*{{\ttfamily condition}}

Type\+: {\ttfamily Boolean$\vert$\+String$\vert$\+Reg\+Exp$\vert$\+Function$<$(node, comment) -\/$>$ Boolean$\vert$\+Object$>$}

Condition what comments you need extract.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        extractComments: \{}
\DoxyCodeLine{          condition: 'some',}
\DoxyCodeLine{          filename: (fileData) => \{}
\DoxyCodeLine{            // The "{}fileData"{} argument contains object with "{}filename"{}, "{}basename"{}, "{}query"{} and "{}hash"{}}
\DoxyCodeLine{            return `\$\{fileData.filename\}.LICENSE.txt\$\{fileData.query\}`;}
\DoxyCodeLine{          \},}
\DoxyCodeLine{          banner: (licenseFile) => \{}
\DoxyCodeLine{            return `License information can be found in \$\{licenseFile\}`;}
\DoxyCodeLine{          \},}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}


\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30369}%
\Hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30369}%
\doxysubparagraph*{{\ttfamily filename}}

Type\+: {\ttfamily String$\vert$\+Function$<$(string) -\/$>$ String$>$} Default\+: {\ttfamily \mbox{[}file\mbox{]}.LICENSE.\+txt\mbox{[}query\mbox{]}}

Available placeholders\+: {\ttfamily \mbox{[}file\mbox{]}}, {\ttfamily \mbox{[}query\mbox{]}} and {\ttfamily \mbox{[}filebase\mbox{]}} ({\ttfamily \mbox{[}base\mbox{]}} for webpack 5).

The file where the extracted comments will be stored. Default is to append the suffix {\ttfamily .LICENSE.\+txt} to the original filename.

\begin{quote}
⚠️ We highly recommend using the {\ttfamily txt} extension. Using {\ttfamily js}/{\ttfamily cjs}/{\ttfamily mjs} extensions may conflict with existing assets which leads to broken code. \end{quote}
{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        extractComments: \{}
\DoxyCodeLine{          condition: /\string^\(\backslash\)**!|@preserve|@license|@cc\_on/i,}
\DoxyCodeLine{          filename: 'extracted-\/comments.js',}
\DoxyCodeLine{          banner: (licenseFile) => \{}
\DoxyCodeLine{            return `License information can be found in \$\{licenseFile\}`;}
\DoxyCodeLine{          \},}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}


\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30370}%
\Hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30370}%
\doxysubparagraph*{{\ttfamily banner}}

Type\+: {\ttfamily Boolean$\vert$\+String$\vert$\+Function$<$(string) -\/$>$ String$>$} Default\+: {\ttfamily /$\ast$! For license information please see \$\{comments\+File\} $\ast$/}

The banner text that points to the extracted file and will be added on top of the original file. Can be {\ttfamily false} (no banner), a {\ttfamily String}, or a {\ttfamily Function$<$(string) -\/$>$ String$>$} that will be called with the filename where extracted comments have been stored. Will be wrapped into comment.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        extractComments: \{}
\DoxyCodeLine{          condition: true,}
\DoxyCodeLine{          filename: (fileData) => \{}
\DoxyCodeLine{            // The "{}fileData"{} argument contains object with "{}filename"{}, "{}basename"{}, "{}query"{} and "{}hash"{}}
\DoxyCodeLine{            return `\$\{fileData.filename\}.LICENSE.txt\$\{fileData.query\}`;}
\DoxyCodeLine{          \},}
\DoxyCodeLine{          banner: (commentsFile) => \{}
\DoxyCodeLine{            return `My custom banner about license information \$\{commentsFile\}`;}
\DoxyCodeLine{          \},}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30371}{}\doxysubsection{Examples}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30371}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30372}{}\doxysubsubsection{Preserve Comments}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30372}
Extract all legal comments (i.\+e. {\ttfamily /$^\wedge$\textbackslash{}$\ast$$\ast$!$\vert$@preserve$\vert$@license$\vert$@cc\+\_\+on/i}) and preserve {\ttfamily /@license/i} comments.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        terserOptions: \{}
\DoxyCodeLine{          output: \{}
\DoxyCodeLine{            comments: /@license/i,}
\DoxyCodeLine{          \},}
\DoxyCodeLine{        \},}
\DoxyCodeLine{        extractComments: true,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30373}{}\doxysubsubsection{Remove Comments}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30373}
If you avoid building with comments, use this config\+:

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        terserOptions: \{}
\DoxyCodeLine{          output: \{}
\DoxyCodeLine{            comments: false,}
\DoxyCodeLine{          \},}
\DoxyCodeLine{        \},}
\DoxyCodeLine{        extractComments: false,}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30374}{}\doxysubsubsection{Custom Minify Function}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30374}
Override default minify function -\/ use {\ttfamily uglify-\/js} for minification.

{\bfseries{webpack.\+config.\+js}}


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  optimization: \{}
\DoxyCodeLine{    minimize: true,}
\DoxyCodeLine{    minimizer: [}
\DoxyCodeLine{      new TerserPlugin(\{}
\DoxyCodeLine{        // Uncomment lines below for cache invalidation correctly}
\DoxyCodeLine{        // cache: true,}
\DoxyCodeLine{        // cacheKeys: (defaultCacheKeys) => \{}
\DoxyCodeLine{        //   delete defaultCacheKeys.terser;}
\DoxyCodeLine{        //}
\DoxyCodeLine{        //   return Object.assign(}
\DoxyCodeLine{        //     \{\},}
\DoxyCodeLine{        //     defaultCacheKeys,}
\DoxyCodeLine{        //     \{ 'uglify-\/js': require('uglify-\/js/package.json').version \},}
\DoxyCodeLine{        //   );}
\DoxyCodeLine{        // \},}
\DoxyCodeLine{        minify: (file, sourceMap) => \{}
\DoxyCodeLine{          // https://github.com/mishoo/UglifyJS2\#minify-\/options}
\DoxyCodeLine{          const uglifyJsOptions = \{}
\DoxyCodeLine{            /* your `uglify-\/js` package options */}
\DoxyCodeLine{          \};}
\DoxyCodeLine{}
\DoxyCodeLine{          if (sourceMap) \{}
\DoxyCodeLine{            uglifyJsOptions.sourceMap = \{}
\DoxyCodeLine{              content: sourceMap,}
\DoxyCodeLine{            \};}
\DoxyCodeLine{          \}}
\DoxyCodeLine{}
\DoxyCodeLine{          return require('uglify-\/js').minify(file, uglifyJsOptions);}
\DoxyCodeLine{        \},}
\DoxyCodeLine{      \}),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30375}{}\doxysubsection{Contributing}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30375}
Please take a moment to read our contributing guidelines if you haven\textquotesingle{}t yet done so.

./.github/\+CONTRIBUTING.\+md \char`\"{}\+CONTRIBUTING\char`\"{}\hypertarget{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30376}{}\doxysubsection{License}\label{md_sfcode_node_modules_terser_webpack_plugin_README_autotoc_md30376}
\href{./LICENSE}{\texttt{ MIT}} 