Search code examples
csssasscompass-sass

Can compass merge .css files?


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?


Solution

  • 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.