Giter Club home page Giter Club logo

sass-rails's Introduction

Official Ruby-on-Rails Integration with Sass

This gem provides official integration for Ruby on Rails projects with the Sass stylesheet language.

Installing

Since Rails 3.1, new Rails projects will be already configured to use Sass. If you are upgrading to Rails 3.1 you will need to add the following to your Gemfile:

gem 'sass-rails'

Configuration

To configure Sass via Rails set use config.sass in your application and/or environment files to set configuration properties that will be passed to Sass.

Options

  • preferred_syntax - This option determines the default Sass syntax and file extensions that will be used by Rails generators. Can be :scss (default CSS-compatible SCSS syntax) or :sass (indented Sass syntax).

The list of supported Sass options can be found on the Sass Website with the following caveats:

  • :style - This option is not supported. This is determined by the Rails environment. It's :expanded only on development, otherwise it's :compressed.
  • :never_update - This option is not supported. Instead set config.assets.enabled = false
  • :always_update - This option is not supported. Sprockets uses a controller to access stylesheets in development mode instead of a full scan for changed files.
  • :always_check - This option is not supported. Sprockets always checks in development.
  • :syntax - This is determined by the file's extensions.
  • :filename - This is determined by the file's name.
  • :line - This is provided by the template handler.

Example

MyProject::Application.configure do
  config.sass.preferred_syntax = :sass
  config.sass.line_comments = false
  config.sass.cache = false
end

Important Note

Sprockets provides some directives that are placed inside of comments called require, require_tree, and require_self. DO NOT USE THEM IN YOUR SASS/SCSS FILES. They are very primitive and do not work well with Sass files. Instead, use Sass's native @import directive which sass-rails has customized to integrate with the conventions of your Rails projects.

Features

Glob Imports

When in Rails, there is a special import syntax that allows you to glob imports relative to the folder of the stylesheet that is doing the importing.

  • @import "mixins/*" will import all the files in the mixins folder
  • @import "mixins/**/*" will import all the files in the mixins tree

Any valid ruby glob may be used. The imports are sorted alphabetically.

NOTE: It is recommended that you only use this when importing pure library files (containing mixins and variables) because it is difficult to control the cascade ordering for imports that contain styles using this approach.

Asset Helpers

When using the asset pipeline, paths to assets must be rewritten. When referencing assets use the following asset helpers (underscored in Ruby, hyphenated in Sass):

asset-path($relative-asset-path)

Returns a string to the asset.

  • asset-path("rails.png") returns "/assets/rails.png"

asset-url($relative-asset-path)

Returns a url reference to the asset.

  • asset-url("rails.png") returns url(/assets/rails.png)

As a convenience, for each of the following asset classes there are corresponding -path and -url helpers: image, font, video, audio, javascript, stylesheet.

  • image-path("rails.png") returns "/assets/rails.png"
  • image-url("rails.png") returns url(/assets/rails.png)

asset-data-url($relative-asset-path)

Returns a url reference to the Base64-encoded asset at the specified path.

  • asset-data-url("rails.png") returns url(data:image/png;base64,iVBORw0K...)

Running Tests

$ bundle install
$ bundle exec rake test

If you need to test against local gems, use Bundler's gem :path option in the Gemfile and also edit test/support/test_helper.rb and tell the tests where the gem is checked out.

Code Status

  • Travis CI
  • Gem Version

sass-rails's People

Contributors

alietz avatar andreis13 avatar arthurnn avatar betterwithranch avatar bjfish avatar carlosantoniodasilva avatar chriseppstein avatar dhh avatar fudoshiki avatar grk avatar guilleiguaran avatar jeremy avatar joenoon avatar jonleighton avatar josevalim avatar josh avatar jsmestad avatar k0kubun avatar kentaro avatar matthewd avatar olivierlacan avatar rafaelfranca avatar robertomiranda avatar robin850 avatar schneems avatar spastorino avatar teeparham avatar tenderlove avatar wycats avatar y-yagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sass-rails's Issues

Loud comments get stripped out

Because compression is separate from compilation with sprockets, loud comments will be stripped out when the sass compressor runs because the bang is stripped out during the first pass.

Sass will need an option to leave the loud comment marker in the output in order to fix this.

dependency on bcrypt?

According to my findings, there is a dependency on bcrypt somewhere related to sass-rails.
I couldn't find it in the gemspec for sass-rails, nor the gems mentioned there.

When issueing gem install sass-rails on our servers (our web servers don't have a compiler on board, since they're web servers :), gem tries to install bcrypt-ruby-3.0.1.

The dependency on bcrypt has been explicitly removed in rails 3.1.1rc1, but this gem still depends on it somewhere.

Is this dependency necessary? Or should I be barking up another gem's issues list? :)

asset helpers with custom paths

It would be awesome if the asset helpers allowed for custom paths. This is needed in order to write applications that can be deployed under any subdirectory, subdirectories, or at the root.

Example usage:

image-url("nav_bg.png", "../assets");

would compiles to

url(../assets/nav_bg-78ce4921cd8bd8512d8e054273d49015.png);

Is there any way to achieve this now and if not does this seem like a feature you would want implemented?

Can't use SASS variable from @imported partial in assets

rake assets:precompile shows a SASS error in the following sample application, and I don't think it should
https://github.com/pwnall/sass_vars_bug/

The app code is generated using rails new from rails 3.1.0.rc4. The only changes that I made were

I tried this both against Rails 3.1.0.rc4 and against the 3-1-stable branch. Any ideas what's going wrong here?

Asset helpers don't compile in Microsoft filter statements

The title may be a bit specific, but this is the only case I've tried. I imagine this could potentially happen in other cases too. I've been using Fancybox (Fancybox.net) and they have some IE filters. While trying to convert the file to use assets, I hit this bug:

.fancybox-ie6 #fancybox-close {
    background: transparent;
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=image_path('fancybox/fancy_close.png'), sizingMethod='scale');
}

I converted the file to have an scss ending and other image_paths are working fine, it's just the ones in this hacky IE filter stuff. I imagine this is falling outside of some of the parsing rules, but I haven't looked at the sass/sass-rails code yet.

Just to note, this is running on Rails 3.1 final.

Custom importers not loaded/ working

I created a custom sass importer in my rails initializers (so its defined for sure) like

module Sass
  module Importers
    class Sprite < Base
      ...
    end
  end
end

which should basically be used for all @import "sprite:xxx" imports. However it's never called, as I get

Sass::SyntaxError: File to import not found or unreadable: sprite:icons.
Load path: Sass::Rails::Importer(.../application.scss)

Failing tests under 1.9.2 with rvm

I'm trying to get the tests to run. I tried on both Ubuntu 11.04 and OSX, using MRI 1.9.2-p180 installed with rvm. These tests are failing for me in both cases (trace included below). I did a vanilla checkout of the 3-1-stable branch, and then bundle install.

I've been trying to read out the code in sass-rails and sprockets, but I haven't been able to figure it out yet. Help would be awesome! I hope that, at the very least, README.markdown can be improved after figuring out the root issue.

Thank you!

pwnage:sass-rails victor$ bundle exec rake test
Loaded suite /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_test_loader
Started
........E.E.....
Finished in 61.836125 seconds.

  1) Error:
test_sass_asset_paths_work(SassRailsTest):
NoMethodError: undefined method `assets' for nil:NilClass
  (in /Users/victor/workspace/sass-rails/test/fixtures/scss_project/app/assets/stylesheets/application.css.scss)
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-07ea84a03b2a/actionpack/lib/sprockets/helpers/rails_helper.rb:96:in `asset_environment'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-07ea84a03b2a/actionpack/lib/sprockets/helpers/rails_helper.rb:20:in `asset_paths'
    /Users/victor/workspace/sass-rails/test/support/sass_rails_test_case.rb:51:in `asset_paths_with_testing'
    /Users/victor/workspace/sass-rails/lib/sass/rails/template_handlers.rb:23:in `public_path'
    /Users/victor/workspace/sass-rails/lib/sass/rails/helpers.rb:26:in `public_path'
    /Users/victor/workspace/sass-rails/lib/sass/rails/helpers.rb:6:in `asset_path'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/script/funcall.rb:80:in `_perform'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/script/node.rb:40:in `perform'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:215:in `visit_prop'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:18:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `map'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `block in visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:230:in `visit_rule'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:18:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `map'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `block in visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:47:in `visit_root'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:18:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:7:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/root_node.rb:20:in `render'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/engine.rb:291:in `_render'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/engine.rb:238:in `render'
    /Users/victor/workspace/sass-rails/lib/sass/rails/template_handlers.rb:75:in `evaluate'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/tilt-1.3.2/lib/tilt/template.rb:76:in `render'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/context.rb:107:in `block in evaluate'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/context.rb:104:in `each'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/context.rb:104:in `evaluate'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/bundled_asset.rb:22:in `initialize'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:118:in `new'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:118:in `build_asset'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:100:in `find_asset_in_path'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:72:in `find_asset'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment.rb:89:in `find_asset'
    /Users/victor/workspace/sass-rails/test/support/sass_rails_test_case.rb:62:in `sprockets_render'
    /Users/victor/workspace/sass-rails/test/sass_rails_test.rb:62:in `block in <class:SassRailsTest>'

  2) Error:
test_sass_imports_work_correctly(SassRailsTest):
NoMethodError: undefined method `assets' for nil:NilClass
  (in /Users/victor/workspace/sass-rails/test/fixtures/scss_project/app/assets/stylesheets/application.css.scss)
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-07ea84a03b2a/actionpack/lib/sprockets/helpers/rails_helper.rb:96:in `asset_environment'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/bundler/gems/rails-07ea84a03b2a/actionpack/lib/sprockets/helpers/rails_helper.rb:20:in `asset_paths'
    /Users/victor/workspace/sass-rails/test/support/sass_rails_test_case.rb:51:in `asset_paths_with_testing'
    /Users/victor/workspace/sass-rails/lib/sass/rails/template_handlers.rb:23:in `public_path'
    /Users/victor/workspace/sass-rails/lib/sass/rails/helpers.rb:26:in `public_path'
    /Users/victor/workspace/sass-rails/lib/sass/rails/helpers.rb:6:in `asset_path'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/script/funcall.rb:80:in `_perform'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/script/node.rb:40:in `perform'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:215:in `visit_prop'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:18:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `map'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `block in visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:230:in `visit_rule'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:18:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `map'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:53:in `visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `block in visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:47:in `visit_root'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/base.rb:37:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:18:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/visitors/perform.rb:7:in `visit'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/tree/root_node.rb:20:in `render'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/engine.rb:291:in `_render'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sass-3.1.4/lib/sass/engine.rb:238:in `render'
    /Users/victor/workspace/sass-rails/lib/sass/rails/template_handlers.rb:75:in `evaluate'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/tilt-1.3.2/lib/tilt/template.rb:76:in `render'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/context.rb:107:in `block in evaluate'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/context.rb:104:in `each'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/context.rb:104:in `evaluate'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/bundled_asset.rb:22:in `initialize'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:118:in `new'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:118:in `build_asset'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:100:in `find_asset_in_path'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:72:in `find_asset'
    /Users/victor/.rvm/gems/ruby-1.9.2-p180/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment.rb:89:in `find_asset'
    /Users/victor/workspace/sass-rails/test/support/sass_rails_test_case.rb:62:in `sprockets_render'
    /Users/victor/workspace/sass-rails/test/sass_rails_test.rb:48:in `block in <class:SassRailsTest>'

16 tests, 23 assertions, 0 failures, 2 errors, 0 skips

Test run options: --seed 21057
rake aborted!
Command failed with status (1): [/Users/victor/.rvm/rubies/ruby-1.9.2-p180/...]

Tasks: TOP => test
(See full trace by running task with --trace)

load_path issue? when changing environment to staging on 3-1-stable

Hi,

I have an issue which I have been stuck on for now 2 days and seem to be associated with sass-rails and Rails 3.1.0 final (and rc8 before). I am using the latest snapshot from the 3-1-stable branch.

In my .css.scss files, I do @import "global" to include global.css.scss which has my mixins and vars.

When RACK_ENV and RAILS_ENV = development, everything works fine. As soon as I run with RACK_ENV and RAILS_ENV = staging, pre-compilation fails:

Error compiling CSS asset

Sass::SyntaxError: File to import not found or unreadable: global.
Load path: /Users/tarik/Documents/mojo/app/mojo
   (in /Users/tarik/Documents/mojo/app/mojo/app/assets/stylesheets/browser_alert.css.scss

  /Users/tarik/Documents/mojo/app/mojo/app/assets/stylesheets/browser_alert.css.scss:1

I noticed that the load path doesn't include the stylesheet directory, but why would this change when the environment is changed to staging? I have tried using monkey patches used to inject the load_path but I then stumble upon a new compilation issue (syntax issue near with /* lin without further indications).

This is truly driving me crazy... I've tried RAILS_GROUPS=assets rake assets:clean tmp:clear no succes, pre-compilation in the command line gives:

Macintosh-7:mojo tarik$ RAILS_GROUPS=assets bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
Invalid CSS after "/* lin": expected identifier, was "/"
  (in /Users/tarik/Documents/mojo/app/mojo/app/assets/stylesheets/application.css)

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

but running without environment set (default is development) or setting it explicitly to development and everything is fine in the browser.

It gets even better changing the environment to production make things works (staging and production environment setting around in the application are all identical). Then changing the environment back to staging again works! This is because for some reason, in production, the compiled assets land in /public/assets (folder gets created) and then the staging reuse that. When I clean it up, I am back to the issue.

I have an identical issue on Heroku cedar (where my staging environment was supposed to be in the first place), but the above trick doesn't even work, /public being non-writable. Somehow the production environment on Heroku correctly write the assets in /tmp -- and clear them when restarting the app with the env set to staging.

Thanks for your help/hints... To me this has to be an inconsistency with rails/sass-rails, but at this point my brain is foggy and hurting, so I apologize in advance if it turns out I am not posting this issue in the right place.

Getting "undefined method `sass_config'" on rails 3.1-stable and sass-rails 3.1.2

When running rake assets:precompile:

/ruby-1.9.2-p180/bin/ruby /bin/rake assets:precompile
rake aborted!
undefined method `sass_config' for #<Class:0x00000102f46ac0>
  (in /app/assets/stylesheets/application.css.scss.erb)

(See full trace by running task with --trace)
rake aborted!

Works fine under rails 3.1.0 and sass-rails 3.1.2, except for that bug where it complains about 'image not precompiled' even though it is, which is supposedly fixed in rails 3.1.1.

Minimum dependency on tilt 1.3.0

In a Rails 3.1 project, I believe only Sprockets has the explicit dependency on Tilt. Its version requirements for tilt are ["~> 1.1", "!= 1.3.0"]. But sass-rails needs at least version 1.3.0 of tilt which adds default_mime_type on Template class.

Perhaps sass-rails should add the explicit tilt dependency as '~>1.3.2' to avoid collision with sprockets '!= 1.3.0' requirement.

Not respecting Relative Root URL

I'm running an application in a folder via Passenger, which I've configured via RackBaseURI. All the Rails routes and helpers respect this and correctly prepend the /folder to paths. Helpers in my sass files don't do this, and always start with /assets instead of /folder/assets.

Is there a configuration setting I'm missing somewhere?

image-url('layout/button_norm_states.png') produces url(/assets/layout/button_norm_states.png) instead of url(/folder/assets/layout/button_norm_states.png)

autocompile in rails 3.1

I got the following errors after upgrading to rails 3.1:

Started GET "/assets/application.css" for 127.0.0.1 at 2011-09-19 22:32:18 -0700
Served asset /application.css - 404 Not Found (2ms)

ActionController::RoutingError (No route matches [GET] "/assets/application.css"):

Rendered /home/jc/.rvm/gems/ruby-1.9.2-p290@myapp/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.7ms)

Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2011-09-19 22:32:18 -0700
Served asset /application.js - 304 Not Modified (0ms)

Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2011-09-19 22:32:18 -0700
Served asset /jquery.js - 304 Not Modified (1ms)

Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2011-09-19 22:32:18 -0700
Served asset /jquery_ujs.js - 304 Not Modified (2ms)

Can anyone see what's going on? I have an assets folder. My other sass files are in .css.scss subfix

Is documentation for helpers correct?

I am trying to determine if I'm doing something wrong, but the documentation and tests both seem to be incorrect for helpers.

The tests and docs both reference image-url('something.png') as resolving a correct asset path, but this wasn't working for me. I dug into the helpers and found them defined in lib/sass/rails/helpers.rb as image_url('something.png') (note _ instead of -). I changed my calls and they are working.

I tried to get the tests to run but a bundle install && rake test with a clean gemset in RVM didn't work for me so I didn't dig too deeply. Am I missing something here? I'm on rails 3.1 and sass-rails 3.1.4.

Make compression style configurable to ensure compatibilty with Webkit

I just migrated http://beta.ruby-toolbox.com to Rails 3.1 and was already using compass and sass before. I already bumped into this issue before, but it has reappeared now and I can't give you exact reasons for this right now, but the issue is this:

If CSS is compressed into 1 single line, Webkit browsers (I at least can confirm this on Chrome and Safari) will eventually mess up and only display part of the defined styles. As I said, I can't currently tell you why this happens and exactly when, but it is the case for example when Rails 3.1 and sass-rails precompiled this css into a single line (this is the fixed version of it): http://assets3.ruby-toolbox.com/assets/preview-67460b20d3e23954001364afc2b08da1.css

I also had this issue before Rails 3.1 with plain Compass and had to adjust the compression settings back then as well.

TL;DR

  • The default of :style => :compressed in https://github.com/rails/sass-rails/blob/master/lib/sass/rails/compressor.rb can lead to big and hard to diagnose trouble
  • The default is hard-coded, even though there is config.sass.style in the Railtie (but maybe that's for development mode? Also, since an instance of CssCompressor is created in the Railtie, config options set after sass-rails being loaded won't be respected, right?)
  • Using :style => :nested solved the problem for me as the rules have newlines again (see the linked css file). To accomplish this, I had to re-open the CssCompressor class and overwrite the whole thing to change the style.

I'm also not sure if :compressed is so much better than :nested as a default when I think of the potential headaches people could get from this. On the linked (gzipped) CSS file, the difference between those was +0.3 KB on a 6 KB file, so I think it is negligible. But I don't want this to result in a big discussion about CSS compression. It's just that in the current state my CSS breaks on Rails 3.1 and I have to hack around the problem, which is not ideal :)

font-url fails with URLs that contain ? or # in production

The font-url method doesn't properly handle URLs that use the FontSpring syntax, e.g. the ones produced from FontSquirrel.
e.g.
src: font-url('aller_rg-webfont.eot?#iefix') format('embedded-opentype'),

The following URLs aren't parsed correctly as they have ? or # afterwards. This is needed to work around handle IE7/8 issues and for older iOS browsers.

Asset helper not interpreted

Hi,

I am using scss with Rails 3.1.0rc6 and sass-rails 3.1.0rc6, it does work well but the helper image-url("test/test.png") is not interpreted. I have a valid output css file but instead of having url(/assets/test/test.png), I have image-url("test/test.png").

Asset fingerprints

I might be missing something, but shouldn't the asset_path/url helpers output a fingerprint when the digest option is enabled? My precompiled stylesheets in production do not contain fingerprints, so I believe the image requests are being handled by sprockets and not served directly from the server. Is there a reason for doing it this way, or am I not configured properly, or does it not matter?

uninitialized constant Sass::Rails::SassTemplate in production

After migrating from Rails 3.0.10 to 3.1.0 i get this error on my production server (in development app works ok):

gems/sass-rails-3.1.0/lib/sass/rails/railtie.rb:38:in `block in <class:Railtie>': uninitialized constant Sass::Rails::SassTemplate (NameError)

Changing @imports does not trigger re-processing of stylesheet

Given a project setup such as:

# ./app/assets/stylesheets/screen.css.scss
@import 'reset';
@import 'typography';

When changing the partial, _typography.scss for example, the application log shows:

20:40:51 application.1  | Started GET "/assets/screen.css" for 127.0.0.1 at 2011-08-10 20:40:51 +0200
20:40:51 application.1  | Served asset /screen.css - 304 Not Modified (0ms)

and has failed to update the CSS file.

undefined method `asset_environment' for class `Sprockets::Railtie' (NameError)

Stack trace:

/Users/chris/Projects/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method': undefined method `asset_environment' for class `Sprockets::Railtie' (NameError)
    from /Users/chris/Projects/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
    from ./lib/sass/rails/monkey_patches.rb:7:in `included'
    from ./lib/sass/rails/monkey_patches.rb:23:in `include'
    from ./lib/sass/rails/monkey_patches.rb:23
    from ./lib/sass/rails.rb:9:in `require'
    from ./lib/sass/rails.rb:9
    from ./test/test_helper.rb:6:in `require'
    from ./test/test_helper.rb:6
    from /Users/chris/Projects/sass-rails/test/sass_rails_logger_test.rb:1:in `require'
    from /Users/chris/Projects/sass-rails/test/sass_rails_logger_test.rb:1
    from /Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:9:in `require'
    from /Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:9
    from /Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:9:in `each'
    from /Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:9
    from /Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:5:in `each'
    from /Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:5

undefined method `static_root='

hey, I'm getting the following output when starting rails server under 1.9.2 with rails 3.1 rc5:

/home/christoph/.rvm/gems/ruby-1.9.2-p180@endeavour/gems/actionpack-3.1.0.rc5/lib/sprockets/railtie.rb:49:in asset_environment': undefined methodstatic_root=' for #Sprockets::Environment:0x000000051ca228 (NoMethodError)
from /home/christoph/.rvm/gems/ruby-1.9.2-p180@endeavour/gems/sass-rails-3.1.0.rc.5/lib/sass/rails/monkey_patches.rb:11:in asset_environment_with_sass_config' from /home/christoph/.rvm/gems/ruby-1.9.2-p180@endeavour/gems/railties-3.1.0.rc5/lib/rails/railtie/configurable.rb:30:inmethod_missing'
from /home/christoph/.rvm/gems/ruby-1.9.2-p180@endeavour/gems/actionpack-3.1.0.rc5/lib/sprockets/railtie.rb:22:in `block in class:Railtie'

can anyone tell me what causes this? gem is included as gem 'sass-rails'

undefined method `context_class' for nil:NilClass

Using rails (3.1.0)
Using sass (3.1.8)
Using sass-rails (3.1.4)

activesupport-3.1.0/lib/active_support/whiny_nil.rb:48:in method_missing': undefined methodcontext_class' for nil:NilClass (NoMethodError)
from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/sass-rails-3.1.4/lib/sass/rails/railtie.rb:61:in block in <class:Railtie>' from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/initializable.rb:25:ininstance_exec'
from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/initializable.rb:25:in run' from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/initializable.rb:50:inblock in run_initializers'
from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/initializable.rb:49:in each' from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/initializable.rb:49:inrun_initializers'
from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/application.rb:92:in initialize!' from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:inmethod_missing'
from /Users/csaba/Devel/xxxxxxx/config/environment.rb:5:in <top (required)>' from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:inrequire'
from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in block in require' from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:inblock in load_dependency'
from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in new_constants_in' from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:inload_dependency'
from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in require' from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/application.rb:78:inrequire_environment!'
from /Users/csaba/.rvm/gems/ruby-1.9.3-rc1/gems/railties-3.1.0/lib/rails/commands.rb:22:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'

Filenames in asset helpers require quotes

Is there any reason why the following couldn't be made to work:

#logo { background-image: image_url(logo.png); }

Currently you have to enclose the path in quotes - unless there's no file extension, e.g:

#logo { background-image: image_url('logo.png'); }
#logo { background-image: image_url(logo); }

Since url() doesn't use quotes it means that when converting a CSS file to SCSS you have to wrap all the paths if you want to use the asset helpers.

Cache saving error on mixins with arguments still present under 3.1.0

Despite this having been closed a while ago. There is still a major issue with caching/compiling Sass stylesheets which reference mixins that take arguments.

I have an .action class defined in a _buttons.css.sass partial. It calls +cleverButton($from: #fff, $to: #000), a fairly complex custom mixin.

This is the initial log output when I start my app:

Started GET "/assets/application.css" for 127.0.0.1 at 2011-08-31 09:58:08 -0400
Compiled application.css  (18ms)  (pid 64520)
Compiled devices.css  (2832ms)  (pid 64520)
Warning. Error encountered while saving cache /Users/***/appfolder/tmp/cache/sass/5e1f39aa3b922c886bbeacd60b380f543cbf520a/_buttons.css.sassc: can't dump anonymous class #<Class:0x007f998a391388>
Compiled hotels.css  (4113ms)  (pid 64520)
Compiled info.css  (1ms)  (pid 64520)
Compiled info_pages.css  (1ms)  (pid 64520)
Compiled info_sections.css  (1ms)  (pid 64520)
Compiled normalize.css  (26ms)  (pid 64520)
Compiled orders.css  (1ms)  (pid 64520)
Compiled pages.css  (279ms)  (pid 64520)
Compiled scaffolds.css  (8ms)  (pid 64520)
Compiled service_options.css  (1ms)  (pid 64520)
Compiled services.css  (1893ms)  (pid 64520)
Warning. Error encountered while saving cache /Users/***/appfolder/tmp/cache/sass/5e1f39aa3b922c886bbeacd60b380f543cbf520a/_buttons.css.sassc: can't dump anonymous class #<Class:0x007f998a391388>
Compiled style.css  (13805ms)  (pid 64520)
Compiled users.css  (1911ms)  (pid 64520)
Compiled jquery-ui-1.8.7.custom.css  (1ms)  (pid 64520)
Compiled jSlider.css  (0ms)  (pid 64520)
Compiled smoke.css  (0ms)  (pid 64520)
Compiled 100s.css  (0ms)  (pid 64520)
Compiled tipTip.css  (0ms)  (pid 64520)
Served asset /application.css - 304 Not Modified (25050ms)

25 seconds to compile all of that, and we're talking about an early stage app which is sparsly-styled (although using Compass).

By comparison, all JavaScript vendor libraries and application scripts take 2612ms to compile.

And here's what happens after initial app bootup (above) if I change a single line in one of the stylesheets.

Started GET "/assets/application.css" for 127.0.0.1 at 2011-08-31 10:11:36 -0400
Warning. Error encountered while saving cache /Users/***/appfolder/tmp/cache/sass/5e1f39aa3b922c886bbeacd60b380f543cbf520a/_buttons.css.sassc: can't dump anonymous class #<Class:0x007fdacb0f8428>
Compiled style.css  (14568ms)  (pid 64578)
Compiled application.css  (22ms)  (pid 64578)
Served asset /application.css - 200 OK (14639ms)

14 seconds this time, every single time I change the simplest thing on a stylesheet. Does anyone else see something like this on Rails 3.1 with sass-rails 3.1 and Compass 0.12.alpha.0?

uninitialized constant Sprockets::Engines (NameError)

Hello, using the latest rails master branch I get an exception when starting the app, I switched from a working 1aa7dae setup:

remote: git://github.com/rails/sass-rails.git
-revision: 1aa7daeb0a32648aeec4a3705b24c2b7543f615d
+revision: 9d60bc84906936bce6d67228f1cc2b72e2f33559

Generated at: https://github.com/rails/sass-rails/blob/master/lib/sass/rails/railtie.rb#L37

Stacktrace:

/Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/sass-rails-9d60bc849069/lib/sass/rails/railtie.rb:37:in `block in <class:Railtie>': uninitialized constant Sprockets::Engines (NameError)
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/activesupport/lib/active_support/lazy_load_hooks.rb:34:in `call'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/activesupport/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/activesupport/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/activesupport/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/activesupport/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/railties/lib/rails/application/bootstrap.rb:68:in `block in <module:Bootstrap>'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/railties/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/railties/lib/rails/initializable.rb:25:in `run'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/railties/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/railties/lib/rails/initializable.rb:49:in `each'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/railties/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/railties/lib/rails/application.rb:97:in `initialize!'
from /Users/kain/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/rails-410b0ec1b712/railties/lib/rails/railtie/configurable.rb:30:in `method_missing'

Helper for asset pipeline "image-tag" renders /images instead of /assets urls

Using latest sass-rails and rails from edge 5.minutes.ago:

gem 'rake', '0.8.7'
gem 'rails', :git => 'git://github.com/rails/rails.git', :branch=>'3-1-stable'

gem 'sprockets'
gem 'jquery-rails'

group :assets do
  gem 'sass-rails', :git => 'git://github.com/rails/sass-rails.git', :branch=>'3-1-stable'
  gem 'coffee-rails', '~> 3.1.0'
  gem 'uglifier'
  gem 'compass', '~> 0.12.alpha'
  gem 'compass-susy-plugin', :require => 'susy'  # http://susy.oddbird.net/tutorial/
  gem 'oily_png' # for faster compass sprite PNG compilation
end

With latest rails 3-1-stable commit by santiago, image_tag in erb views now works fine, renders /assets/ instead of /images again as in 3.1.0.

But "image-tag('image.png')" in sass and scss still returns /images/image.png instead of /assets/image.png.

Issue with subfolder imports

Given the following folder structure beneath app/assets:

  • nested >
    • nested.css.scss
    • subfolder >
      • importme.scss

Within nested.css.scss, the following works (1):

@import "nested/subfolder/importme";

as well as (2):

@import "./subfolder/importme";

However the following (3) fails:

@import "subfolder/importme";

with the error:

File to import not found or unreadable: subfolder/importme.

This is in a fresh Rails application using edge Rails and sass-rails from HEAD. I would expect (3) to work fine, and the tests suggest so too (partials/_scss_import.css.scss imports subfolder/relative_not_a_partial.css.scss).

Sass::Rails::CssCompressor tries to compile already compiled Scss

Some background: We upgraded our app from Rails 3.0 (with Compass and Jammit) to Rails 3.1 with Asset Pipeline and made it work with Compass master branch (without Jammit). We still need Compass because we use bunch of helpers and sprite generation AP. Specs are passing and the app works in development environment perfectly fine (all our assets are loading).

After running the bundle exec rake assets:precompile I got the "regexp buffer overflow" error.

Some investigation showed that the error occurs because Sass compressor (Sass::Rails::CssCompressor#compressor) receives already compiled CSS file. Our CSS is pretty large, so it seemed plausible that a complex regex chokes.

I'm not sure why is the CSS already compiled. It can be Compass' fault, but I couldn't find any proof to that. I've amended the compress method with this:

puts "First 1024 chars of compiled thing: #{css[0..1023]}"
raise

And here's the output (obviously compiled and compressed):

First 1024 chars of compiled thing: html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,code,del,dfn,em,img,q,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,dialog,figure,footer,header,hgroup,nav,section{margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline}article,aside,dialog,figure,footer,header,hgroup,nav,section{display:block}...

And stack trace:

from gems/sass-rails-3.1.2/lib/sass/rails/compressor.rb:8:in `compress'
from gems/actionpack-3.1.1.rc1/lib/sprockets/compressors.rb:18:in `compress'
from gems/sprockets-2.0.0/lib/sprockets/processing.rb:243:in `css_compressor='
from gems/sprockets-2.0.0/lib/sprockets/processor.rb:29:in `call'
from gems/sprockets-2.0.0/lib/sprockets/processor.rb:29:in `evaluate'
from gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
from gems/sprockets-2.0.0/lib/sprockets/context.rb:175:in `evaluate'
from gems/sprockets-2.0.0/lib/sprockets/context.rb:172:in `each'
from gems/sprockets-2.0.0/lib/sprockets/context.rb:172:in `evaluate'
from gems/sprockets-2.0.0/lib/sprockets/bundled_asset.rb:242:in `build_source'
from gems/sprockets-2.0.0/lib/sprockets/caching.rb:26:in `cache_hash'
from gems/sprockets-2.0.0/lib/sprockets/bundled_asset.rb:235:in `build_source'
from gems/sprockets-2.0.0/lib/sprockets/bundled_asset.rb:71:in `digest'
from gems/sprockets-2.0.0/lib/sprockets/asset.rb:143:in `inspect'

Additionally, the format of the css parameter changes based on the Compass configuration of output_style (a reason to suspect Compass is the culprit).

We worked around the problem by setting the config.asset.css_compressor to nil in after_initialize block. That solves our symptoms, but if I'm right, many more could have their css compiled twice without errors (if their CSS output is simpler or smaller).

I'm not really sure whose "fault" this is (maybe we're doing something wrong?), but I needed to start the discussion somewhere :)

UPDATE: when I deployed to the staging server, I discovered that the CSS is not compressed at all. However I still get the same error when I enable compression, which probably just means that Compass does not compress CSS for staging environment. I'll double-check and update the issue.

UPDATE 2: Compass was just not compressing for staging environment, that was fixed in compass config.

something like raw for scss files

Hello. I have scss file. I should use this css construction:

  a:before, span:before{
    content: "<ins>1</ins>";
  }

but I have escaped result on my page.

Can I find something like RAW helper for SCSS files?

tnx!

Behavior of image-url helper is not consistent with documentation

From the documentation for https://github.com/rails/sass-rails

For example: image-url("rails.png") becomes url(/assets/rails.png) and image-path("rails.png") becomes "/assets/rails.png".

Sounds good, so here's an excerpt from a sass file:

background: image-url("some-image/path.gif") top left no-repeat

Let's look at how it gets compiled:

background: url('/images/some-image/path.gif') top left no-repeat; }

This fails because the path should start with /assets, not /images. According to the readme, the path should have started with /assets.

It could be that I am doing something wrong here but I can't figure out what it would be. I have one sass file and to my knowledge it does not include anything that would somehow override the image-url helper.

"File to import not found or unreadable" for dynamically created file

application.scss.erb

<%File.open("app/assets/stylesheets/new.scss","w"){|f|f.write("body{background-color:#f00;}")}%>
@import "new";

rake assets:precompile

File to import not found or unreadable: new.
Load path: Sass::Rails::Importer(/home/gucki/test/app/assets/stylesheets/application.scss.erb)
  (in /home/gucki/test/app/assets/stylesheets/application.scss.erb)

When running the task again (new.scss exists now) it works without any problems.

So it seems to be some caching issue...

Doesn't handle importing partials within folders

I was directed here from https://github.com/sstephenson/sprockets/issues/130#issuecomment-1620934
Here's a copy and paste of the issue, which I'm told belongs here:

This is part of the directory tree of my app/assets/stylesheets:

admin/
    meals.css.scss
application.css
partials/
    _menu.css.scss

In my meals.css.scss file, I have this at the top:

@import "partials/menu";

...which works nicely...

But when I add

gem 'sprockets'

to my Gemfile, I get the following error:

Sass::SyntaxError: File to import not found or unreadable: partials/menu.

When I move the _menu.css.scss partial up a level so it's simply in app/assets/stylesheets, this error goes away.

It's unclear to me where the problem lies because I actually have had gem 'sass-rails' for a while and things seemed to work fine.. only when I added gem 'sprockets' did this issue arise.

Overwrite SASS partials in engines

One of the most powerful features of Rails engines is the ability to overwrite app/ classes. I am looking for the same functionality in scss. I think it would be quite useful for customizing engines' CSS. Example:

Lets say we have a scss file in my_engine/app/assets/stylesheets/base.css.scss with:

@import "colors";

...

An the related partial in my_engine/app/assets/styleseets/_colors.scss

$dark: #001100;
...

I'd love to be able to create a file in my_app/app/assets/styleseets/_color.scss that overwrites the colors from the engine. This way I can easily customize the colors and images without having to copy all the code from the stylesheets. What do you think about it?

I does not seem to work with sass-rails-3.1.3 and rails-3.1.1.rc2. I am digging in the code but I get lost between importers and contexts!

compass and sass-rails not working in 3.1.0.rc2?!

I'm trying to get compass to run with 3.1.0.rc2/sass-rails: Previously (rails 3.1.0.rc1), I had a sass.rb in config/initializers, that made the compass-framework-scss available like this:

Sass::Engine::DEFAULT_OPTIONS[:load_paths].tap do |load_paths|
  load_paths << "#{Rails.root}/app/assets/stylesheets"
  load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"
  load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/blueprint/stylesheets"
end

That was already a bit hackish, but at least it worked - now with 3.1.0.rc2 and sass-rails I'm getting
'''
Sass::SyntaxError: File to import not found or unreadable: blueprint.
'''

for all the compass-stylesheets. If have seen, that sass-options are now set via config.sass.<option>- but the simplistic:

config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"
config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/blueprint/stylesheets" 

is not working, as config.sass.load_paths is nil. Any ideas how to feed sass-rails these additional paths?!

image_url helper return image?timestamp value

during rake assets:precompile
image_url helper generates urls like url('/images/bg/header-bg.png?1309532519')

other helpers like
image_path, assets_path, image_path helpers generates everything as declared
ex: /assets/bg/header-bg-e34a5f7f87e031630061700743210712.png

looks like naming overlaps with compass.

tild integration of scss support broken

When trying to use the new sass-rails helpers like "image-path" an exception occurs:

scss:
  body {
    background: image-url("body/1.png");
  }

Exception:

ActionView::Template::Error in UsersController#show

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]

sass-rails (3.1.2) lib/sass/rails/helpers.rb:31:in `public_path'
sass-rails (3.1.2) lib/sass/rails/helpers.rb:15:in `asset_url'
sass-rails (3.1.2) lib/sass/rails/helpers.rb:25:in `image_url'
sass (3.1.7) lib/sass/script/funcall.rb:88:in `_perform'
sass (3.1.7) lib/sass/script/node.rb:40:in `perform'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:215:in `visit_prop'
sass (3.1.7) lib/sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.7) lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
sass (3.1.7) lib/sass/tree/visitors/base.rb:53:in `map'
sass (3.1.7) lib/sass/tree/visitors/base.rb:53:in `visit_children'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:39:in `with_environment'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:26:in `visit_children'
sass (3.1.7) lib/sass/tree/visitors/base.rb:37:in `block in visit'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:235:in `visit_rule'
sass (3.1.7) lib/sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.7) lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
sass (3.1.7) lib/sass/tree/visitors/base.rb:53:in `map'
sass (3.1.7) lib/sass/tree/visitors/base.rb:53:in `visit_children'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:39:in `with_environment'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:26:in `visit_children'
sass (3.1.7) lib/sass/tree/visitors/base.rb:37:in `block in visit'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:47:in `visit_root'
sass (3.1.7) lib/sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.7) lib/sass/tree/visitors/perform.rb:7:in `visit'
sass (3.1.7) lib/sass/tree/root_node.rb:20:in `render'
sass (3.1.7) lib/sass/engine.rb:293:in `_render'
sass (3.1.7) lib/sass/engine.rb:240:in `render'
tilt (1.3.3) lib/tilt/css.rb:24:in `evaluate'
tilt (1.3.3) lib/tilt/template.rb:76:in `render'
slim (1.0.2) lib/slim/embedded_engine.rb:124:in `render'
slim (1.0.2) lib/slim/embedded_engine.rb:100:in `on_slim_embedded'
slim (1.0.2) lib/slim/embedded_engine.rb:180:in `on_slim_embedded'
slim (1.0.2) lib/slim/embedded_engine.rb:82:in `on_slim_embedded'
(eval):43:in `dispatcher'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:49:in `compile'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `block in on_multi'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `each'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `on_multi'
(eval):34:in `dispatcher'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:49:in `compile'
temple (0.3.4) lib/temple/html/dispatcher.rb:19:in `on_html_tag'
(eval):27:in `dispatcher'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:49:in `compile'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `block in on_multi'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `each'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `on_multi'
(eval):34:in `dispatcher'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:49:in `compile'
temple (0.3.4) lib/temple/html/dispatcher.rb:19:in `on_html_tag'
(eval):27:in `dispatcher'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:49:in `compile'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `block in on_multi'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `each'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:7:in `on_multi'
(eval):34:in `dispatcher'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:49:in `compile'
temple (0.3.4) lib/temple/mixins/dispatcher.rb:45:in `call'
temple (0.3.4) lib/temple/engine.rb:49:in `block in call'
temple (0.3.4) lib/temple/engine.rb:49:in `each'
temple (0.3.4) lib/temple/engine.rb:49:in `inject'
temple (0.3.4) lib/temple/engine.rb:49:in `call'
temple (0.3.4) lib/temple/templates/rails.rb:30:in `call'
actionpack (3.1.1.rc1) lib/action_view/template.rb:253:in `compile'
actionpack (3.1.1.rc1) lib/action_view/template.rb:190:in `compile!'
actionpack (3.1.1.rc1) lib/action_view/template.rb:143:in `block in render'
activesupport (3.1.1.rc1) lib/active_support/notifications.rb:55:in `instrument'
actionpack (3.1.1.rc1) lib/action_view/template.rb:142:in `render'
...

Modify to work in any Rack app

See this pull request.

I think the Sprockets+Sass integration should not be a feature unique to Rails apps. The Sass templates provided by this gem would work fine, with some minor changes, in any app that uses Sprockets.

Understandably, the gem is named "sass-rails", so maybe it wouldn't make sense in this project. But if you like this idea, I'd be happy to work on a pull request. Otherwise, I will start a separate "sprockets-sass" (or "sass-sprockets"?) gem.

Assets paths for SASS-files

If I have a SASS partial, which uses some context (sass-variables, mixins, extends other classes), it should be included in main sass file using @import (which prevents me from using Tilt's ability to use ERB), but that causes problems for images: I can't use something like that:

  body { 
    background: url('background.png');
  }

cause on production this image will be precompiled and would have another name (with md5-hash).

asset_url helpers don't look in vendor/assets for images

If I use image-url or asset-url to reference an image in a .scss file, whether in an engine or in app/assets/stylesheets, the image won't be found during compilation if it is in vendor/assets/images. Everything works fine if the assets aren't compiled.

I assume this has something to do with a difference in the paths used for resolving filenames in Rails (which supports vendor/assets/images) and in Sass.

I can provide a test case or dig into this further if required, let me know.

asset-data-uri helper?

I was trying to use

asset-data-uri('foo.png')

in my .scss files in the same fashion as asset-path() or image-url(), but it seems such helper is missing (Sprockets provides asset_data_uri). Possible to add?

Rails 3.1.0.rc4 Sass Cache error message

In the above version using the asset pipeline with compass and sass-rails, I am getting an error message on compilation.

The error messages and files that may be relevant are shown in this gist git://gist.github.com/1018153.git.

I am not sure whether this is a compass, rails 3.1 or sass-rails issue but it is definitely behavior not seen in previous versions of rails. Furthermore, wondering whether compilation is supposed to be as slow as I am experiencing e or if there are settings to speed it up - as currently experienced for me compilation is very slow and was wondering whether the errors have something to do with it.

If not a rails 3.1 issue let me know and I will report or open an issue on the responsible group.

My asset pipeline is successfully able to import compass partials and render the css.

Originally filed by @dbkbali.

Tests require 1.9.2

I tried running the tests on MRI 1.8.7 and they failed with errors like

NoMethodError: undefined method `spawn' for #<SassRailsTest:0x7f54c2071160>

The errors don't show up in MRI 1.9.2, so I think the Running Tests section in README.markdown should mention that running the tests requires 1.9.2. I can make a pull request if this seems like a reasonable change.

Rails 3.1 generator for stylesheets: error with namespaces

I ran a generator to create the superadmin/organizations_controller.

Naturally, stylesheet generation occurred, and I was pleased to see the assets/stylesheets/superadmin/organizations.css.scss. However, the next time I ran "rails server" I found that there was an error in my css and all my styling on the page vanished.

The generator created the following, which is invalid:

// Place all the styles related to the superadmin/organizations controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

body.superadmin/organizations {
  // Place scoped styles here
}

I just changed the / (slash) to a _ (underscore) to resolve the problem. I thought I should let someone here know.

image-url helper only works on development

I am using image-url("image.png") in my .scss file to correctly insert the asset path there.
In development it works great. But in production the compiled .css file still has image-url("image.png") and not url(/assets/images-#####.png).

My environment:

in development.rb:

  config.assets.compress = false
  config.assets.debug = true

in production.rb:

  config.assets.compress = false
  config.assets.compile = true
  config.assets.digest = true

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.