3

I'm using grunt-contrib-compass to process my .SCSS files

compass: {
  dist: {
    options: {
      cssDir: 'www/styles',
      sassDir: 'www/styles',
      imagesDir: 'www/images',
      javascriptsDir: 'www/scripts',
      force: true
    }
  }
},

And I'm using grunt-contrib-watch to watch which file has been changed.

watch: {
  compass: {
    files: [
      'www/styles/**/*.{scss,sass}'
    ],
    tasks: ['compass']
  }
}

After generting the .CSS files, I want to minify it using grunt-contrib-cssmin. But when I do it like tasks: ['compass', 'cssmin'], the second time I need to minify the file, it doesn't override it, it appends instead. So if the first time the file is 10kb, the next time I save it become 20kb and so on and so on..

What's the correct way of doing it?

4

2 回答 2

3

您可以在每次编译之前使用 grunt-contrib-clean 删除目标目录中的所有内容:

https://github.com/gruntjs/grunt-contrib-clean

运行之前的任务compass,您将确保避免与旧代码发生任何冲突。

于 2013-06-06T05:23:18.773 回答
1

Compass 还可以缩小文件;output_style = :compressed查看 Compass 的配置参考以获取更多信息。

我更喜欢config.rb改用;

compass: {
    dest: {
        config: 'config.rb',
        force: true
    }
},
于 2014-09-16T14:19:47.500 回答