Search code examples
sasscompass-sass

Using Compass (sass) features without compass project


My problem: I want to use some compass features (mostly sprites generation and css3 mixins), but I don't want to create a compass project for it. My project structure should be a bit more complicated than compass allows me to create. So I'd like to stay in my project with sass, but import and use some compass features in it. Is it possible?


Solution

  • Compass IS able to manage all your stuff. Just give it a try.

    Here's an example, this is the structure of a Compass project i'm currently working on:

    enter image description here

    First of all, you should have a folder like sass where you store your non-partial SASS files, e. g. sass/style.sass or sass/screen.scss. Your config.rb should point at it.

    Then create a subfolder called partials where you store all the stuff.

    In partials subfolder you start creating the structure:

    sass/
      partials/
        _global.sass
        _modules.sass
      style.sass
    

    The contents of your style.sass should be like this:

    @import partials/global
    @import partials/modules
    

    This structure is easily extendable. Once your partial grows large and you decide to split it, just create a subfolder named after the partial, create smaller partials there and import them from the initial partial:

    sass/
      partials/
        global/
          _extendables.sass
          _functions.sass
          _mixins.sass
          _variables.sass
        _global.sass
        _modules.sass
      style.sass
    

    Contents of _global.sass:

    @import global/extendables
    @import global/functions
    @import global/mixins
    @import global/variables
    

    This makes your project structure easily extendable.

    Note that if you're using the SCSS syntax, quotes are necessary in the import statements, e. g. @import "global/extendables";.

    If the imports aren't working for you, please share your project structure, the exact code you use and the error text you receive.