Concatenate . Sass files with Compass

Asked

Viewed 523 times

3

I am trying to concatenate (unify) several . css files generated from SASS and I am using Compass to process my files.

I’m using Grunt to perform some tasks, including concatenating files, but as I try to join the files . generated css, many of the classes are repeating themselves in the file with the unified files. That is, duplicating everything that was created.

Does anyone know if Compass does this type of concatenation by default, beyond the understanding of the files?

2 answers

2

You are using https://github.com/yeoman/grunt-usemin? If not, it can help you in the concatenation process, just put it in your HTML:

    <!-- build:css({.tmp,app}) styles/main.css -->
    <link rel="stylesheet" href="styles/main.css">
    <link rel="stylesheet" href="bower_components/jquery-ui/themes/ui-lightness/jquery-ui.css">
    <link rel="stylesheet" href="bower_components/jquery-ui/themes/ui-lightness/jquery.ui.theme.css">
    <!-- endbuild -->

And in Grunfile add:

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
        options: {
            dest: '<%%= yeoman.dist %>'
        },
        html: '<%%= yeoman.app %>/index.html'
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
        options: {
            assetsDirs: ['<%%= yeoman.dist %>']
        },
        html: ['<%%= yeoman.dist %>/{,*/}*.html'],
        css: ['<%%= yeoman.dist %>/styles/{,*/}*.css']
    },
  • Thanks, I solved it with your solution. ;)

0

You can create a file main.scss and put in it the @imports of the . scss you want to concatenate. Then compile main.scss:

$ compass compile main.scss

Example of main.scss:

@import 'header.scss';
@import 'footer.scss';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.