Reputation: 1255
I've set up a Vagrant box (precise32) to run the usual Grunt stuff but it's taking way too long.
Running "watch" task
Waiting...OK
>> File "../../home/vagrant/app/wp-content/themes/testcss/_vars.scss" changed.
Running "sass:dist" (sass) task
File "/home/vagrant/app/wp-content/themes/test/css/styles.css" created.
Done, without errors.
Completed in 40.392s at Mon Dec 02 2013 11:34:02 GMT+0000 (UTC) - Waiting...
OK
>> File "../../home/vagrant/app/wp-content/themes/test/css/styles.css" changed.
Completed in 0.000s at Mon Dec 02 2013 11:34:02 GMT+0000 (UTC) - Waiting...
I've tried this on the shared folder and a native folder within the VM with no change. I'm using the grunt-contrib-sass plugin although I've also tried grunt-sass and it takes a similar amount of time. The watch event fires quickly but then the VM consumes all spare CPU utilisation until the CSS compile completes.
Running sass manually takes ~2 seconds
Any idea where to go from here?
package.json
{
"name": "www",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-autoprefixer": "~0.4.0",
"grunt-concurrent": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.3.0",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-google-cdn": "~0.2.0",
"grunt-newer": "~0.5.4",
"grunt-ngmin": "~0.0.2",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.2.0",
"grunt-usemin": "~2.0.0",
"jshint-stylish": "~0.1.3",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.1",
"karma-ng-scenario": "~0.1.0",
"grunt-karma": "~0.6.2",
"karma-chrome-launcher": "~0.1.0",
"karma-script-launcher": "~0.1.0",
"karma-firefox-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.3",
"requirejs": "~2.1.9",
"karma-requirejs": "~0.2.0",
"karma-coffee-preprocessor": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.0",
"karma": "~0.10.5",
"karma-ng-html2js-preprocessor": "~0.1.0",
"grunt-contrib-sass": "~0.5.1",
"grunt-php": "~0.3.0"
},
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "grunt test"
}
}
EDIT:
I've found out roughly where the problem lies. It is that whenever my grint-contrib-sass task is triggered from grunt-contrib-watch it actually reloads all of Grunt's modules. I cannot see why it is doing this nor why this would be necessary. I've changed the question title to reflect this.
Upvotes: 2
Views: 575
Reputation: 3065
We've had mediocre success with this issue using jit-grunt. What we've done is we've replaced load-grunt-tasks
with jit-grunt
in Gruntfile.js
. The execution of grunt serve
went down from 20-30 seconds to less than 4 seconds. The bottleneck is now probably compass:server
load and this is related to slow Shared folder
.
Still doing Karma test runs without grunt (just using karma-cli
) -- alot faster this way.
Upvotes: 0
Reputation: 1255
I've found out that this seems to be due to the spawn option. Setting this to false stops the whole reload.
I now have the problem that the watch reloads when the sass compiler task runs so that livereload on the watched css files isn't always working.
Upvotes: 0
Reputation: 9358
Unless you are giving a lot of cpu to vagrant (normally it use 1 cpu core i believe), i will expect grunt to run slower than your host machine. If you are not using nfs
then slow IO will be the next suspect.
We use grunt in vagrant as well but only with a small number of packages (mostly contrib
plugin), on an iMac it takes about 2 second in vagrant, so your issue may indeed be the slow IO or certain package having to do a lot of file operations.
If you isolate your grunt watch
to sass plugin alone, does it take the same amount of time when compare to running grunt sass
manually? how about running on your host machine?
Another point to consider is try not to watch the files that will be generated by grunt, you might get into strange issues if a grunt task triggers another.
Upvotes: 1