1.npm install --save-dev grunt-contrib-watch 安裝 watchcss
2.安裝chrome livereload 插件html
3.配置Gruntfile.jschrome
watch: {
client: {
files: ['*.html', '*.css', '*.js'],
options:{
livereload: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('live', ['watch']);
npm
4.執行grunt live 並開啓chrome 中livereload 插件瀏覽器
5.編輯文件,能夠看到同步刷新了grunt
感想:真的很好用,兩個顯示器的時候 極大的提高了工做效率,特別在後期調整小的樣式的時候 不用F5了插件
好像還有一種方式是使用connect-livereload ,不須要瀏覽器插件,尚未嘗試htm
參考文檔:blog
http://www.bluesdream.com/blog/grunt-plugin-livereload-wysiwyg-editor.html文檔