错误
Running "less" task
Running "less:files" (less) task
Verifying property less.files exists in config...OK
Warning: Object #<Object> has no method 'indexOf' Use --force to continue.Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
files: [
{
expand: true,
cwd: 'public/css',
src: ['*.less'],
dest: 'public/css',
ext: '.css'
}
],
options: {
compress: true,
yuicompress: true,
optimization: 2
}
},
watch: {
files: "public/css/*",
tasks: ["less"]
},
});
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-less");
grunt.loadNpmTasks("grunt-contrib-requirejs");
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['less', 'watch']);
};任何帮助都非常感谢,谢谢。
发布于 2014-06-02 16:28:38
files在上面的配置中被解释为一个目标。因为它位于任务级别,而不是在目标级别。
只有当您要定义每个目标多个src/ files块时,才需要files属性。
由于您只有一个src/dest块,所以修改您的配置以只使用一个目标:
less: {
targetname: {
expand: true,
cwd: 'public/css',
src: ['*.less'],
dest: 'public/css',
ext: '.css'
},
options: {
compress: true,
yuicompress: true,
optimization: 2
}
},targetname的名称是任意的,可以任意命名。
需要使用files的一个示例是以下多个src/dest块配置:
less: {
targetname: {
files: [
{ src: ['*.less'], dest: 'public/css/' },
{ src: ['other/*.less'], dest: 'other/css/' },
]
},
options: {
compress: true,
yuicompress: true,
optimization: 2
}
},https://stackoverflow.com/questions/23996506
复制相似问题