npm build 打包前端项目实际上是执行 node build/build.js,但是随着项目的依赖包越来越多,项目打包时间不断延长,为了改善这个问题,需要从node入手

暂时解决方案:扩大node运行程序的内存,经本人测试(项目和机器固定)

2G:308.11s

4G:284.96s

6G:280.94s

8G:277.63s

10G:277.86s

因此看出设定为8G差不多,因为再往后效果已经不明显了

设定方法:

在package.json文件中将命令修改,也可以在执行命令的时候添加,

例如:

node --max-old-space-size=8192 server.js  


在package.json文件修改
"scripts": {
    "dev": "node build/dev-server.js",
    "build": "node --max-old-space-size=8192 build/build.js",//这里设定的是8G
    "lint": "eslint --ext .js,.vue src",
    "update": "rm -rf node_modules theme && yarn && et"
  }

 

 

相关文章:

  • 2021-09-03
  • 2021-07-16
  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-07-03
  • 2021-12-15
  • 2021-04-20
  • 2021-12-10
相关资源
相似解决方案