1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Added :sass_assets_path for external SASS repositories

Compass is great, but sometimes we need to have common framework code in one (global) location with local overrides in the app.

This addition adds built-in support for loading SASS/SCSS files from multiple locations external to the "source" directory and even the Middleman app root.

Example usage:

    # in config.rb

    set :sass_assets_path, [ "#{root}/assets/sass/", "~/.sass-repo/"]

Using symlinks or copying files to the Middleman project can get messy quickly.  This fix reduces some of those issues.
This commit is contained in:
kematzy 2012-07-16 16:50:02 +08:00 committed by Thomas Reynolds
parent 6f0f9b00a2
commit 3ea2241155
7 changed files with 41 additions and 0 deletions

View file

@ -109,6 +109,11 @@ module Middleman
# @return [String]
set :css_dir, "stylesheets"
# Location of SASS/SCSS files external to source directory.
# @return [Array]
# set :sass_assets_paths, ["#{root}/assets/sass/", "/path/2/external/sass/repository/"]
set :sass_assets_paths, []
# Location of images within source. Used by HTML helpers and Compass.
# @return [String]
set :images_dir, "images"

View file

@ -0,0 +1,11 @@
Feature: Support SASS assets paths
In order to import common shared assets when writing Sass
Scenario: Importing assets from 'assets/stylesheets/' directory in app root
Given the Server is running at "sass-assets-path-app"
When I go to "/stylesheets/plain.css"
Then I should see "color: green;"
Then I should see "/* Works with shared SCSS assets from APPROOT/assets/stylesheets/_shared-asset.scss */"
Then I should see "/* Works with shared SASS assets from APPROOT/assets/stylesheets/_shared-asset.sass */"
Then I should see "font-size: 18px"
Then I should see "/* Works with shared SASS assets from external source directory */"

View file

@ -0,0 +1 @@
/* Works with shared SASS assets from APPROOT/assets/stylesheets/_shared-asset.sass */

View file

@ -0,0 +1 @@
/* Works with shared SCSS assets from APPROOT/assets/stylesheets/_shared-asset.scss */

View file

@ -0,0 +1,6 @@
set :sass_assets_paths, [
"#{root}/assets/stylesheets/",
# load from another app within gem source
"#{File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))}/fixtures/preview-app/source/stylesheets/"
]

View file

@ -0,0 +1,16 @@
red
color: green
/* imports below
// SCSS with extension
@import "_shared-asset.scss"
// without extension
@import "shared-asset"
// imported from outside of local 'assets/' directory
@import "_partial.sass"
/* Works with shared SASS assets from external source directory */

View file

@ -23,6 +23,7 @@ module Middleman
config.environment = :development
config.cache_path = sass_cache_path
config.sass_dir = css_dir
config.additional_import_paths = sass_assets_paths
config.css_dir = css_dir
config.javascripts_dir = js_dir
config.fonts_dir = fonts_dir