Grunt sass多个dest文件

时间:2014-12-17 16:12:21

标签: gruntjs

让我们看看grunt sass模块的这部分配置:

dev: {
    src: 'dev/sass/style.scss',
    dest: '../site/web/assets/css/style.css',
    options: {
        style: 'expand',
        compass: true
    }
}

这可以按预期工作。现在我希望Grunt将我的scss文件编译到2个目的地,所以我尝试了:

dev: {
    src: 'dev/sass/style.scss',
    dest: ['../site/web/assets/css/style.css','another/path/style.css']
    options: {
        style: 'expand',
        compass: true
    }
}

但它返回错误:

Warning: Unable to write "../site/web/assets/css/style.css,another/path/style.css" file (Error code: undefined). Use --force to continue.

有可能吗?我做错了什么?

1 个答案:

答案 0 :(得分:2)

dest必须是字符串而不是数组。您无法定义多个目标文件。

你应该使用

Files Object Format

dev: {
    options: {
        style: 'expand',
        compass: true
    },
    files: {
        '../site/web/assets/css/style.css': ['dev/sass/style.scss'],
        'another/path/style.css': ['dev/sass/style.scss']
    }
}

Files Array Format

dev: {
    options: {
        style: 'expand',
        compass: true
    },
    files: [
      {src: ['dev/sass/style.scss'], dest: '../site/web/assets/css/style.css'}, 
      {src: ['dev/sass/style.scss'], dest: 'another/path/style.css'} 
    ]
}