CSS and SASS in Rails

A good article about organising CSS/SASS in Rails

http://www.mattboldt.com/organizing-css-and-sass-rails/

Basically you have this in yourapp/assets/stylesheets/application.css /* NOTE: Not Application.scss */

/*
    *= require_self
    *= require main
*/
Then you keep the files in this directory structure
Directory structure:
    assets/
        stylesheets/
            application.css

                /*
                 *= require_self
                 *= require main
                 */
             main.scss
                 base
                     mixins.scss
                     globals.scss
                     normalize.scss
                 styles
                     posts.scss
                     home.scss

And then you @import everything from main.scss

app/assets/stylesheets/main.scss

@import "base/mixins.scss";
@import "base/normalize.scss";
@import "base/globals.scss";
@import "styles/home.scss";
@import "styles/posts.scss";

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.