问题:开启 sentry 配置,导致构建内存泄漏
默认构建配置
使用1个Worker,内存限制为2048MB
处理方式:
// Modifying node memory limits
export NODE_OPTIONS="--max-old-space-size=8192"
// 或者修改 SourceMap 生成方式(最低成本)
// https://v3.umijs.org/zh-CN/guide/boost-compile-speed#调整-sourcemap-生成方式
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
configureWebpack: config => {
// get a reference to the existing ForkTsCheckerWebpackPlugin
const existingForkTsChecker = config.plugins.filter(p => p instanceof ForkTsCheckerWebpackPlugin)[0];
// remove the existing ForkTsCheckerWebpackPlugin
// so that we can replace it with our modified version
config.plugins = config.plugins.filter(p => !(p instanceof ForkTsCheckerWebpackPlugin));
// copy the options from the original ForkTsCheckerWebpackPlugin
// instance and add the memoryLimit property
const forkTsCheckerOptions = existingForkTsChecker.options;
// modification the workers
forkTsCheckerOptions.workers = 2;
// modification the memoryLimit
forkTsCheckerOptions.memoryLimit = 12288;
config.plugins.push(new ForkTsCheckerWebpackPlugin(forkTsCheckerOptions));
}
};
修改后居然提升了构建速度
Before
Now