Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt is insanely slow on a clean yeoman angular-generate setup

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

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.

like image 397
iuliust Avatar asked Nov 02 '22 03:11

iuliust


1 Answers

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
  },
like image 151
garst Avatar answered Nov 12 '22 14:11

garst