Css 使用Grunt监视较少文件的目录
我当前的Grunt代码:Css 使用Grunt监视较少文件的目录,css,gruntjs,less,Css,Gruntjs,Less,我当前的Grunt代码: module.exports = function(grunt) { grunt.initConfig({ // running `grunt less` will compile once less: { development: { options: { paths: ["custom"],
module.exports = function(grunt) {
grunt.initConfig({
// running `grunt less` will compile once
less: {
development: {
options: {
paths: ["custom"],
yuicompress: true
},
files: {
"custom/file1.css": "custom/*.less",
"custom/file2.css": "custom/*.less"
}
}
},
// running `grunt watch` will watch for changes
watch: {
files: "custom/*.less",
tasks: ["less"]
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', ['less:development']);
};
与其指定两个单独的文件“file1”和“file2”,我更希望它编译并查看“custom”中的所有.less文件。显然,您必须使用重命名回调:
files: [{
src: ['custom/*.less'],
expand: true,
rename: function(dest, src) { return dest + src.replace('.less', '.css') },
dest: ''
}]
来源:显然,您必须使用重命名回调:
files: [{
src: ['custom/*.less'],
expand: true,
rename: function(dest, src) { return dest + src.replace('.less', '.css') },
dest: ''
}]
来源:请参阅(有关特定示例,请参阅)。(还要注意,
yuicompress
选项大约在两年前从grunt contrib less
中删除)。请参阅(有关特定示例,请参阅)。(还要注意,yuicompress
选项大约在两年前从grunt contrib less
中删除)。这非常有效,谢谢。您刚刚错过了结尾处的“]”结束方括号。但一旦我加上这一点,它实现了一个梦想。这很好,谢谢。您刚刚错过了结尾处的“]”结束方括号。但一旦我补充了这一点,它就实现了一个梦想。