diff --git a/packages/docusaurus/src/webpack/base.ts b/packages/docusaurus/src/webpack/base.ts index 0e033852d7..3c7c9acf3a 100644 --- a/packages/docusaurus/src/webpack/base.ts +++ b/packages/docusaurus/src/webpack/base.ts @@ -38,6 +38,17 @@ export function excludeJS(modulePath: string): boolean { ); } +// See https://github.com/webpack-contrib/terser-webpack-plugin#parallel +let terserParallel: boolean | number = true; +if (process.env.TERSER_PARALLEL === 'false') { + terserParallel = false; +} else if ( + process.env.TERSER_PARALLEL && + parseInt(process.env.TERSER_PARALLEL, 10) > 0 +) { + terserParallel = parseInt(process.env.TERSER_PARALLEL, 10); +} + export function createBaseConfig( props: Props, isServer: boolean, @@ -103,7 +114,7 @@ export function createBaseConfig( ? [ new TerserPlugin({ cache: true, - parallel: true, + parallel: terserParallel, sourceMap: false, terserOptions: { parse: {