vue-cli 项目 打包gc 优化

222 阅读1分钟

当执行vue-cli-service build,产生gc报错时,打包优化配置

//vue.config.js
  parallel: true, // 开启多进程打包
  productionSourceMap: false, //生产环境不需要source map

node 内存使用打印

const field = "heapUsed";

const TIME_INTERVAL_IN_MSEC = 40;

setInterval(() => {
  const mu = process.memoryUsage();
  // # bytes / KB / MB / GB
  const gbNow = mu[field] / 1024 / 1024 / 1024;
  const gbRounded = Math.round(gbNow * 100) / 100;

  console.log(`Heap allocated ${gbRounded} GB`);
}, TIME_INTERVAL_IN_MSEC);