我个人更喜欢grunt-contrib-watch(https://github.com/gruntjs/grunt-contrib-watch),因为它似乎更灵活。我在Gruntfile.js中定义了哪些文件将被监视以进行更改,并在此事件中订阅我想执行的任何任务。
在dev上。环境项目的网页有reloader脚本,使页面刷新,只要通过发射更新事件咕噜-的contrib手表
<script src="http://localhost:35729/livereload.js"></script>
它正常工作,给我。这里是我的咕噜构建脚本
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks('grunt-jscs');
grunt.initConfig({
// Lint all the files in js folder
jshint: {
options: {
jshintrc: ".jshintrc"
},
all: ["js/**/*.js"]
},
// Validate against jQuery coding standard
jscs: {
options: {
"standard": "Jquery"
},
all: ["js"]
},
// Preprocess SASS
compass: {
dist: {
options: {
sassDir: 'sass',
cssDir: 'css'
}
}
},
watch: {
options: {
livereload: true
},
css: {
files: ['sass/**/*.sass'],
tasks: ['compass']
},
js: {
files: ['js/**/*.js'],
tasks: ['jshint', 'jscs']
}
}
});
grunt.registerTask("lint", ["jshint", "jscs"]);
grunt.registerTask("default", ["watch"]);
};
当你运行咕噜你会得到类似的东西
从我读这就是我想要的。尽管我必须测试它。该网站关闭了几个小时... – 2012-08-18 18:23:46
我认为它现在正在工作,所以检查出来;-) – 2012-08-21 16:08:47
我不能让它在Windows上工作。我插入了JS并使用了浏览器扩展。没有工作。但它看起来像我正在寻找的东西。 – 2012-08-21 20:30:54