7

I am trying to find out if Compass can merge .css files rather than using a third party tool to merge the .css files after Compass has compiled the .scss files. I have looked around the web and on here but nothing so far. I thought the config.rb may have an option for this but all I found is compress feature.

Anyone tried this or have a found a third party tool that works well with compass?

isNaN1247
  • 17,793
  • 12
  • 71
  • 118
Sancho_UK
  • 73
  • 1
  • 6

2 Answers2

16

I'd wanted to do this same thing for quite some time. I finally settled on the following solution.

Take the following structure (i.e. with your modules in a sub-folder of sass)

  • project
    • sass
      • modules
        • header.scss
        • blog-posts.scss
        • footer.scss
        • something-else.scss
      • main.scss
    • stylesheets

Update main.scss to contain:

@import 'modules/header.scss';
@import 'modules/blog-posts.scss';
@import 'modules/footer.scss';
@import 'modules/something-else.scss';

Run the following command (from the project folder) in order to build

compass compile . sass/main.scss -s compressed

This just compiles main.scss, which inturn goes and imports each of your modules. Additionally the compressed style option minifies the output.

isNaN1247
  • 17,793
  • 12
  • 71
  • 118
1

It's not compression, but you can exclude files from being copied to the output directory by prepending an underscore to their names. For example:

scss/
    _core.scss // will not be copied
    theme.scss  // @import 'core';
css/

compass compile
    create ../css/theme.css

css/
    theme.css
alekop
  • 2,838
  • 2
  • 29
  • 47