【发布时间】:2015-03-06 20:45:32
【问题描述】:
我知道有一些非常相似的问题,但我无法解决问题。
我正在使用 grunt,包括 connect、less 和 watch。一切正常,除了使用 less 和 watch 实时编译 .css。像这样,我总是必须重新启动 grunt 等。 这是我的代码:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
server: {
options: {
port: 8000,
hostname: 'localhost',
base: 'public',
keepalive: true
}
}
},
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
"public/style/style.css": "public/style/main.less"
}
}
},
watch: {
files: ['**/*'],
tasks: ['less', 'connect'],
styles: {
files: ['public/style/main.less'], //which files to watch
tasks: ['less'],
options: {
livereload: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['less','connect','watch']);
};
如果需要更多信息,请告诉我。
【问题讨论】:
标签: gruntjs less grunt-contrib-watch