mirror of
https://github.com/scratchfoundation/scratch-webpack-configuration.git
synced 2024-11-27 10:05:37 -05:00
chore: limit Terser threads
This commit is contained in:
parent
56c3806611
commit
e4ad003025
1 changed files with 9 additions and 0 deletions
|
@ -3,6 +3,7 @@ const path = require('path');
|
||||||
const merge = require('lodash.merge');
|
const merge = require('lodash.merge');
|
||||||
const nodeExternals = require('webpack-node-externals');
|
const nodeExternals = require('webpack-node-externals');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
|
const TerserPlugin = require("terser-webpack-plugin")
|
||||||
|
|
||||||
const DEFAULT_CHUNK_FILENAME = 'chunks/[name].[chunkhash].js';
|
const DEFAULT_CHUNK_FILENAME = 'chunks/[name].[chunkhash].js';
|
||||||
const DEFAULT_ASSET_FILENAME = 'assets/[name].[hash][ext][query]';
|
const DEFAULT_ASSET_FILENAME = 'assets/[name].[hash][ext][query]';
|
||||||
|
@ -58,6 +59,14 @@ class ScratchWebpackConfigBuilder {
|
||||||
} : path.resolve(this._srcPath, 'index'),
|
} : path.resolve(this._srcPath, 'index'),
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: isProduction,
|
minimize: isProduction,
|
||||||
|
minimizer: [
|
||||||
|
new TerserPlugin({
|
||||||
|
// Limiting Terser to use only 2 threads. At least for building scratch-gui
|
||||||
|
// this results in a performance gain (from ~60s to ~36s) on a MacBook with
|
||||||
|
// M1 Pro and 32GB of RAM and halving the memory usage (from ~11GB at peaks to ~6GB)
|
||||||
|
parallel: 2
|
||||||
|
})
|
||||||
|
],
|
||||||
...(
|
...(
|
||||||
shouldSplitChunks ? {
|
shouldSplitChunks ? {
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
|
|
Loading…
Reference in a new issue