iuliust iuliust - 15 days ago 4x
AngularJS Question

grunt is insanely slow on a clean yeoman angular-generate setup [solved]

I'm a grunt newbie. My PC runs Windows 7 x64.

I followed the Yeoman tutorial (on the Yeoman site) and I did not change anything in any of the generated files. Then, I ran

grunt serve

When I change any html file, the grunt process is instantaneous, but when I modify one of the .js or .css files, the process is insanely slow. When I hit save, grunt notices it immediately :

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

but there seems to be around 4 long seconds before the next lines appear on the terminal :

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)

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) - Waiting...

I'm confused. grunt says it took him 66ms total to run the tasks, but then it says that it took him 4.463s to complete the whole process.

What did I did wrong ? The build is clean, I did nothing else than

yo angular

to scaffold the app... Any idea ?

edit :

spawn: false

solved my problem. Thanks to the one who brought that up. Even if I use Gulp or webpack nowadays.


There is a spawn option that sometimes make things faster --and also more prone to failing apparently.

From the 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.

You would disable the spawn adding a options section inside watch in your Gruntfile.js. Something like this.

watch: {
  options: {
    spawn: false