我已经设置了一个 Vagrant 盒子(precise32)来运行通常的 Grunt 东西,但它花费的时间太长了。
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...
我已经在虚拟机中的共享文件夹和本机文件夹上尝试了这个,没有任何变化。我正在使用 grunt-contrib-sass 插件,尽管我也尝试过 grunt-sass 并且它需要类似的时间。watch 事件会快速触发,但随后 VM 会消耗所有空闲 CPU 利用率,直到 CSS 编译完成。
手动运行 sass 大约需要 2 秒
知道从这里去哪里吗?
包.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"
}
}
编辑:
我大致发现了问题所在。就是每当我的 grint-contrib-sass 任务从 grunt-contrib-watch 触发时,它实际上会重新加载 Grunt 的所有模块。我看不出它为什么这样做,也看不出为什么有必要这样做。我已更改问题标题以反映这一点。