1

我有不同的选项来连接 JS 文件和 CSS 文件。

如何配置 grunt 来运行这样的配置?

这不起作用:

concat: {
    js: { // Custom options for JS
        options: {
            separator: '\n',
            sourceMap: true,
            banner: '...',
        },
        core: {
            src: ['src/core/*.js', 'src/core/**/*.js'],
            dest: 'assets/xxxx.js'
        }
    },
    css: { // Default options for CSS
        core: {
            src: ['src/core/*.css', 'src/core/**/*.css'],
            dest: 'assets/xxxx.css'
        }
    }
}
4

1 回答 1

3

这很丑陋,但它有效:

grunt.loadNpmTasks('grunt-contrib-concat');

grunt.renameTask('concat', 'concatCss');
grunt.loadNpmTasks('grunt-contrib-concat');
// The task is then loaded two times, under 'concat' and 'concatCss' names.

...
concat: {  
    options: {
        separator: '\n',
        sourceMap: true,
        banner: '...',
    },
    core: {
        src: ['src/core/*.js', 'src/core/**/*.js'],
        dest: 'assets/xxxx.js'
    },
concatCss: { // Default options for CSS
    core: {
        src: ['src/core/*.css', 'src/core/**/*.css'],
        dest: 'assets/xxxx.css'
    }
}
于 2014-11-10T08:11:37.223 回答