Grunt LiveReload真的很慢 [英] Grunt LiveReload is really slow
问题描述
这可能是我的无效设置的影响,而不是grunt / livereload的问题。
This is probably an affect of my inefficient setup and not a problem with grunt/livereload.
这是我的grunfile.js中的观察测试:
Here's my watch test in my grunfile.js:
watch: {
images: {
files: ['images/**/*.{png,jpg,gif}', 'images/*.{png,jpg,gif}'],
tasks: ['imagemin'],
options: {
spawn: false
}
},
js: {
files: ['js/*.js','js/**/*.js'],
tasks: ['jshint'],
options: {
spawn: false
}
},
svgs: {
files: ['images/*.svg','images/**/*.svg'],
task: ['svgmin'],
options: {
span: false
}
},
scss: {
files: ['sass/*.scss', 'sass/**/*.scss'],
tasks: ['sass','autoprefixer'],
sourceComments: 'normal',
options: {
nospawn: true,
livereload: true
}
}
},
这将重新编译我的SASS和重新加载页面,但它需要5-6秒来完成CSS编译,然后
This will recompile my SASS and the reload the page, but it takes 5-6 seconds to complete the CSS compilation, then it does a full page refresh, instead of just reloading the CSS file that changed.
所以我的问题是这样的:
So my questions are this:
-
如何避免这么长时间来编译SASS和刷新页面,或者我只是挑剔,这是grunt的继承的一部分? p>
如何重新载入整个网页,并重新载入从SASS编译变更的CSS档案?
How keep if from reloading the entire page, and just reload the CSS file that changed from my SASS compilation?
推荐答案
检查我的其他答案:最快的方式来编译SCSS(Compass)+刷新浏览器?
grunt-contrib-sass 使用Ruby sass非常慢,它没有什么可以
grunt-contrib-sass uses Ruby sass which is very slow, it has nothing to do with grunt itself.
使用 grunt-sass 而是,它使用libsass,这是照明快速c实现sass。
Use grunt-sass instead, it uses libsass which is lighting fast c implementation of sass.
阅读这篇文章:
http://benfrain.com/lightning-fast-sass-compiling-with-libsass-node-sass-and-grunt-sass/
这篇关于Grunt LiveReload真的很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!