2

我有一个使用 npm 的构建过程,其中在链中注册了几个任务。

package.json 看起来像这样(http/https 的东西是因为代理服务器证书扰乱了 npm):

  "scripts": {
    "git-config": "git config --global --replace-all url.\"https://\".insteadOf git://",
    "bower-install": "node_modules/.bin/bower install",
    "bower": "npm run git-config && npm run bower-install",
    "build": "npm config set registry http://registry.npmjs.org/ && npm config set strict-ssl false && npm install && npm run bower && node build-bundles"
  },

每次启动 npm 或 node 时,似乎有大约 0.5 秒的挂起时间,而在命令完成后但在 npm/node 进程退出之前,还有 1.5 秒的挂起时间。在上面的脚本中,有很多对 npm/node 的调用,这最终使我们的构建时间增加了 15-20 秒(即使没有更改)。

有没有办法:

  • 在 npm/node 退出前至少消除 2 秒挂起
  • 使上述脚本仅在项目文件之一更改时执行(我不想使用 watchify)
  • 否则提高这些脚本的速度

请注意,这个问题与 npm install 的速度、包缓存、包下载速度等没有任何关系。

谢谢。

4

0 回答 0