Grunt在干净的Yeoman Angular生成设置上运行极慢

5

我是一个grunt新手,我的电脑运行的是Windows 7 x64。

我按照Yeoman网站上的教程操作,并且没有更改任何生成文件中的内容。然后,我运行了以下命令:

grunt serve

当我修改任何html文件时,grunt的处理过程是瞬间完成的,但是当我修改其中一个.js或.css文件时,这个过程变得异常缓慢。当我保存时,grunt立即注意到了:

>> File "app\styles\index.css" changed

但似乎在下一行出现在终端之前,大约需要4秒钟的时间:

Running "newer:copy:styles" (newer) task

Running "copy:styles" (copy) task
Copied 1 files

Running "newer-timestamp:copy:styles:R:\Personnel\Workspaces\web\front\plume\node_modules\grunt-newer\.cache" (newer-timestamp)
task

Running "newer-reconfigure:copy:styles:1" (newer-reconfigure) task

Running "autoprefixer:dist" (autoprefixer) task
Prefixed file ".tmp/styles/index.css" created.
Prefixed file ".tmp/styles/main.css" created.

Done, without errors.


Execution Time (2014-03-21 00:00:19 UTC)
loading tasks                                            6ms  ■■■■■ 9%
newer:copy:styles                                        9ms  ■■■■■■■■ 14%
copy:styles                                              7ms  ■■■■■■ 11%
newer-timestamp:copy:style...odules\grunt-newer\.cache   3ms  ■■■ 5%
autoprefixer                                             1ms  ■ 2%
autoprefixer:dist                                       39ms  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 59%
Total 66ms
... Reload .tmp\styles\index.css ...
... Reload .tmp\styles\main.css ...
Completed in 4.463s at Fri Mar 21 2014 01:00:20 GMT+0100 (Paris, Madrid) - 

等待中...

我有些困惑。grunt说它总共花费了66ms来运行任务,但是它又说它花费了4.463秒来完成整个过程。

我做错了什么吗?构建很干净,我除了这个什么都没做。

yo angular

如何搭建应用程序?有任何想法吗?

编辑: spawn: false 解决了我的问题。感谢提出这个想法的人。即使我现在使用Gulp或webpack。


我尝试在我的Linux环境中重现这个问题,但是速度非常快。 - Lajos Veres
1个回答

2

有一个 spawn 选项,有时会使事情变得更快--但显然也更容易失败。

来自文档:

是否在子进程中生成任务运行。将此选项设置为false可加快监视的响应时间(通常对于大多数人而言,快500ms),并允许后续任务运行共享相同的上下文。不生成任务运行可能会导致监视更容易失败,因此请根据需要使用。

您可以在Gruntfile.js中的watch中添加一个options部分来禁用spawn。类似于这样:

watch: {
  options: {
    spawn: false
  },

Usemin目前还不完全支持spawn:false。详情请见:https://github.com/yeoman/grunt-usemin/issues/307 - Lajos Veres
1
没错,spawn: false 让进程速度快了很多。我现在会坚持使用它。谢谢。 - iuliust

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接