title: Page Specific Sass files and Duplication
body: <p>I am really struggling to structure the Sass files in a Rails 3.1 project to avoid massive duplication ...</p>
  
  <p>I have the following structure, with application.css.scss being imported as part of my main layout:</p>
  
  <pre><code>application.css.scss
    - [*= require] main.css.scss
        - [@import] 'variables';
        - [@import]'bootstrap_overrides';
        - [@import]'bootstrap';
        - [@import]'base_elements';
        - [@import]'superstructure';
        - [@import]'modules';
  </code></pre>
  
  <p>So far so good. All these files are combined by sprockets into a single document. However I then want to modularise my Sass further, with page-specific files or files shared across regions of my site.</p>
  
  <p>So on my GalleryResource#show page I need to use additional Sass files:</p>
  
  <pre><code>resource.scss
  gallery_resource.scss
  badges.scss
  </code></pre>
  
  <p>And maybe a css file from a lib:</p>
  
  <pre><code>gallery_lib.scss
  </code></pre>
  
  <p>These files need to reference a number of the files already imported in application.css. They need to make use of variables defined in variables.css.scss and of mixins defined in bootstrap. So I am forced to reimport these files in each file that uses them, causing massive duplication. I could write a manifest file for each and every page, but this is a maintenance nightmare and still results in duplication and two css files; application.css and page_specific.css.</p>
  
  <p>So what is the solution? Do I need to dispence with application.css and move its imports into each page-specific file? So using the above example I would end up with a single manifest file that looks like this:</p>
  
  <pre><code>gallery_resource_manifest.css.scss
        - [*= require] gallery_lib.css
        - [*= require] gallery_resource.css.scss
           - [@import] 'variables';
           - [@import]'bootstrap_overrides';
           - [@import]'bootstrap';
           - [@import]'base_elements';
           - [@import]'superstructure';
           - [@import]'modules';
           - [@import]'resource';
           - [@import]'gallery_resource';
           - [@import]'gallery';
           - [@import]'badges';
  </code></pre>