angularjs - Grunt 在干净的自耕农 Angular 生成设置上非常慢

标签 angularjs gruntjs yeoman

我是一个咕噜咕噜的新手。我的电脑运行 Windows 7 x64。

我遵循了 Yeoman 教程(在 Yeoman 网站上),我没有对任何生成的文件进行任何更改。然后,我跑了

grunt serve

当我更改任何 html 文件时,grunt 过程是即时的,但是当我修改 .js 或 .css 文件之一时,该过程非常缓慢。当我点击保存时,咕噜立即注意到它:
>> 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 说他总共花了 66 毫秒来运行任务,但后来又说他花了 4.463 秒来完成整个过程。

我做错了什么?构建很干净,我什么也没做
yo angular

为应用程序搭建脚手架...知道吗?

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

最佳答案

有一个spawn有时会使事情变得更快的选项——而且显然也更容易失败。

来自 documentation :

Whether to spawn task runs in a child process. Setting this option to false speeds up the reaction time of the watch (usually 500ms faster for most) and allows subsequent task runs to share the same context. Not spawning task runs can make the watch more prone to failing so please use as needed.



您将禁用生成添加 options部分内watch在你的 Gruntfile.js 中。像这样的东西。
watch: {
  options: {
    spawn: false
  },

关于angularjs - Grunt 在干净的自耕农 Angular 生成设置上非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22547999/

相关文章:

javascript - ionic : How to make Angular Translate js working with Search Filter when language changed?

javascript - ng-repeat 和 ng-scrollbar 不能一起工作

yeoman - 包括基于用户选择的依赖项

AngularJS + RequireJS + Bower + Karma + Yeoman + Node

javascript - grunt-contrib-watch 静默退出

javascript - 使用Angular提取特定的Json数据

javascript - ng-repeat 不显示最后一段文字

c# - 运行 child_process.execFile 后 uglify 崩溃

css - Postcss 和 grunt 或 gulp 有什么区别?

javascript - grunt 中的 less 文件观察器不更新 css