grunt中的browserSync出现问题。它编译我的少到CSS和缩小的CSS。但是当我在html文件中进行更改时,Browsersync不会重新加载。每当我在html文件中进行更改时,都需要重新启动grunt,以更新localhost。有谁知道该怎么办?
这是我的gruntfile.js代码:
module.exports = function(grunt) {
require('jit-grunt')(grunt);
grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
"css/style.css": "less/style.less" // destination file and source file
}
}
},
watch: {
styles: {
files: ['less/**/*.less'], // which files to watch
tasks: ['less'],
options: {
nospawn: true
}
}
},
cssmin: {
minify: {
src: 'css/style.css',
dest: 'css/minified/style.min.css'
}
},
browserSync: {
dev: {
bsFiles: {
files : [
'css/minified/style.min.css',
'./'
]
},
options: {
watchTask: true,
server: './'
}
}
},
watch: {
css: {
files: 'less/style.less',
tasks: ['less','cssmin']
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-browser-sync');
grunt.registerTask('default', ['less','browserSync','watch']);
};