Having a hard time figuring out how to make SASS, not SCSS, as the default for stylesheets.
I've tried making a sass_config.rb
file with this:
Sass::Plugin.options[:syntax] = :sass
Sass::Plugin.options[:style] = :compressed
I've also tried adding that to the environment.rb file. Either way I get this error:
.../config/environment.rb:7:in `<top (required)>':
uninitialized constant Sass::Plugin (NameError)
I found this answer somewhere else, can't remember exactly, but put this in
config/initializers/sass.rb
:I also prefer SASS syntax (to SCSS). All you have to do is name files
mystylesheet.css.sass
instead and it just works. You can even rename yourapplication.css
toapplication.css.sass
, change the comments at the top to//
instead of/* */
and use therequire_*
directives—it all works, and then you can use SASS in your application global stylesheet. It won't if you use compass inapp/stylesheets
.Don't require the
Sass::Plugin
, it's totally separate to the new Rails asset engine which is based on Sprockets. It already knows how to compile SASS for you and manages the bundling of assets properly.I imagine a new Compass release will do this automatically for Rails 3.1+ projects using the asset pipeline.
For rails 3.1.rc4, you could set the config:
in the
application.rb
fileDo
require 'sass/plugin'
and make sure it's at the bottom after yourApplication.initialize!
call.I definitely prefer sass to scss too - have you considered just using the compass gem for all your CSS, and adding
preferred_syntax = :sass
to config/compass.rbI haven't tested this out yet on rails 3.1 yet but it works in 3.0.7
EDIT
As a troubleshooting step, what happens when you remove just the first line of code from sass_config.rb so that it just has the second one? Do both these lines cause the error?
As @krainboltgreene commented, adding the following line to
config/application.rb
makes
sass
the default format for stylesheet generators. However, since Rails 3.1.beta1 doesn't support it, one gets the following error messagesAs you see, one cannot change the default format without breaking the generators. Instead, you can manually create extra *.css.sass files, which are working fine with or without scss ones.
I added the following to
config/environments/development.rb
:That did the trick.