开发者

Can I configure SASS such that the scss files aren't in the web root?

It looks like SASS by default exposes scss files which I find rath开发者_JAVA技巧er obnoxious. Is there a way to configure SASS to look for scss files in a folder that's not in the web root but compile them into the public/stylesheets folder?


Yes!

If you use Compass, then you'll have a file /config/compass.rb that'll look like the following. Here I have my sass files in app/stylesheets and saving compiled in tmp/stylesheets (to help with heroku deployments)

/config/compass.rb

# This configuration file works with both the Compass command line tool and within Rails.
# Require any additional compass plugins here.
project_type = :rails
project_path = Compass::AppIntegration::Rails.root
#project_path = RAILS_ROOT if defined?(RAILS_ROOT)
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "tmp/stylesheets"
sass_dir = "app/stylesheets"
environment = Compass::AppIntegration::Rails.env
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true


Old question but it's actually simple to do, you just pass the directories through to sass instead of specific .scss like so;

sass --watch /location/to/you/scss/:/location/to/your/css

Then any changes to scss will be saved into your css directory and it will also follow the same structure of your scss directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜