Grunt with Compass and Watch compiles slow

后端 未结 4 1754
既然无缘
既然无缘 2021-02-15 09:23

Grunt takes a quite long to compile the css file, I am not sure if this is normal but regular compass watch takes around 5 seconds.

So the question is if there is any w

4条回答
  •  Happy的楠姐
    2021-02-15 10:15

    I know this question is a few years old at this point but I thought I'd add another potential cause/solution.

    First, try starting your grunt server using --verbose and watch to see where your sass task is taking most of its time. There are plugins that will report the time each part of the tast takes but for me simply watching the --verbose output made it very clear where the delay was. For me, it wasn't the actual sass task, it was the loading unnecessary dependencies.

    As is outlined in this issue on Grunt's GitHub repo, one reason that certain tasks may take a long time to complete is that Grunt loads all tasks everytime it runs. So even though grunt-contrib-watch is only running the compass:dist task when you change your sass files grunt is still loading all tasks and their dependencies.

    There is now a plugin called jit-grunt (or on npm) that addresses this and only loads what is necessary to run your task. This helped my compass task complete much faster.

提交回复
热议问题