如何使用grunt-recess编译2个单独的LESS文件

时间:2013-10-13 17:41:03

标签: css less gruntjs recess twitter-recess

我想用grunt凹槽编译2个单独的文件:

recess: {
            dist: {
                options: {
                    compile: true
                },
                files: {
                    'path/css/custom.css': ['path/less/custom.less'],
                    'path/css/animate.css': ['path/less/antimate.less'],

                },
            },
        }, 

在grunt退出之前,只有第一个文件正在编译。我哪里错了?

2 个答案:

答案 0 :(得分:3)

你应该试试这个

recess: {
    dist: {
        options: {
            compile: true
        },
        files: [
            {src: ['path/less/custom.less'], dest: 'path/css/custom.css'},
            {src: ['path/less/antimate.less'], dest: 'path/css/animate.css'}
        ],
    }
}, 

或者您可以启用动态扩展来编译文件夹中的每个.less:

recess: {
    dist: {
        options: {
            compile: true
        },
        files: [
            {
                expand: true,            // Enable dynamic expansion.
                cwd: 'path/to/less',     // Src matches are relative to this path.
                src: ['*.less'],         // Actual pattern(s) to match.
                dest: 'path/to/css/',    // Destination path prefix.
                ext: '.css',             // Dest filepaths will have this extension.
            },
        ],
    },
}, 

有关详情,请参阅http://gruntjs.com/configuring-tasks

答案 1 :(得分:0)

像这样:

recess: {
    dist: {
        options: {
            compile: true
        },
        files: {
            'dist/combined.css': [
                'src/main.css',
                'src/component.css'
            ]
        }
    }
}
相关问题