Grunt手表任务似乎需要很长时间 [英] Grunt watch tasks seem to take a very long time

查看:124
本文介绍了Grunt手表任务似乎需要很长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行两个简单的任务,每个任务运行时间小于100ms,但在watch命令下运行时,两个组合任务总共花费约8秒(每个任务的开销似乎为3.5秒)。我将它与live-reload一起用于开发,我发现它非常令人沮丧。我试着将 spawn 设置为 false ,但这似乎破坏了它,并且没有任何相关的任务运行。



以下是sass文件更改时的示例输出。

 >> ;文件app / styles / main.scss已更改。 

创建app / styles / main.css文件。

完成,没有错误。

经过时间
加载任务4ms▇▇▇▇▇9%
sass 1ms▇▇2%
sass:dist 39ms▇▇▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇89%
总计44ms
完成3.862s at Mon Nov 18 2013 17:05:57 GMT + 0000(GMT) - Waiting ...
OK
>>文件app / styles / main.css已更改。

运行copy:styles(复制)任务
复制1个文件

完成,没有错误。

经过时间
加载任务4ms▇▇▇▇▇▇▇▇▇▇▇▇24%
复制:款式13ms▇▇▇▇▇▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇76%
总计17ms
在2013年11月18日17:06完成3.704s: 01 GMT + 0000(GMT) - 正在等待...
OK
>>文件.tmp / styles / main.css已更改。

...重新加载.tmp / styles / main.css ...
...重新加载.tmp / styles / main.css ...
完成时间为0.000s在星期一11月18 2013 17:06:01 GMT + 0000(GMT) - 等待...

在node.js 0.10.20上使用grunt 0.4.1(和grunt-cli 0.1.11)。运行于2012 Macbook Air(OS X 10.8.5)解决方案

在文件更改后,请执行任务,但完成后,观看重新加载模块(!)并再次观看。



详细查看问题:

  grunt tasknamewatch --verbose 

我试过在手表上递归任务,但没有成功。

 手表:{
...,
任务:['sometask ','watch']
}

运行良好的简单解决方案是使用咕噜 - 埃斯特手表。您可以在这里阅读所需步骤: https://stackoverflow.com/a/33920834/2741005


I'm running two simple tasks that run for <100ms each but when run under the watch command the two combined tasks are taking ~8 seconds in total (there seems to be an overhead of 3.5 seconds per task). I'm using it with live-reload for development and I'm finding it very frustrating. I tried setting spawn to false but this seemed to break it and none of the associated tasks were run.

Here's sample output from when a sass file is changed.

>> File "app/styles/main.scss" changed.

File "app/styles/main.css" created.

Done, without errors.

Elapsed time
loading tasks   4ms  ▇▇▇▇▇ 9%
sass            1ms  ▇▇ 2%
sass:dist      39ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 89%
Total 44ms
Completed in 3.862s at Mon Nov 18 2013 17:05:57 GMT+0000 (GMT) - Waiting...
OK
>> File "app/styles/main.css" changed.

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

Done, without errors.

Elapsed time
loading tasks   4ms  ▇▇▇▇▇▇▇▇▇▇▇▇ 24%
copy:styles    13ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 76%
Total 17ms
Completed in 3.704s at Mon Nov 18 2013 17:06:01 GMT+0000 (GMT) - Waiting...
OK
>> File ".tmp/styles/main.css" changed.

... Reload .tmp/styles/main.css ...
... Reload .tmp/styles/main.css ...
Completed in 0.000s at Mon Nov 18 2013 17:06:01 GMT+0000 (GMT) - Waiting...

Using grunt 0.4.1 (and grunt-cli 0.1.11) on node.js 0.10.20. Running on 2012 Macbook Air (OS X 10.8.5)

解决方案

After file was changed, watch execute the tasks, but on finished, watch reload the Modules(!) and watched again.

Verbose to see the problem:

grunt tasknamewatch --verbose

I've tried a recursion on the watch task, but no success.

watch: {
    ...,
    tasks: ['sometask', 'watch']
}

An easy solution that worked well, was to use "grunt-este-watch". You can read the required steps here: https://stackoverflow.com/a/33920834/2741005

这篇关于Grunt手表任务似乎需要很长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆