Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 使用Grunt监视较少文件的目录_Css_Gruntjs_Less - Fatal编程技术网

Css 使用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"],

我当前的Grunt代码:

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
中删除)。这非常有效,谢谢。您刚刚错过了结尾处的“]”结束方括号。但一旦我加上这一点,它实现了一个梦想。这很好,谢谢。您刚刚错过了结尾处的“]”结束方括号。但一旦我补充了这一点,它就实现了一个梦想。