Rails assets:precompile strange behavior Rails assets:precompile strange behavior ruby-on-rails ruby-on-rails

Rails assets:precompile strange behavior


I can think of one of two possibilities right now:

1) You should change application.css.scss to application.css.less and use:

@import "custom-style";

instead of the sprockets //= require ...

2) The LESS compiler is very finicky about its semicolons. I noticed that you have @import "custom-style/buttons" - it should be @import "custom-style/buttons";

Dunno if the issue is really that simple, but it's a start.


Have you tried renaming the file to buttons.css.less but keeping the extension off the @import (i.e., @import "buttons")?

That's how I do it with SCSS and it works fine.

Another thought is to replace the //=require custom-style in application.css.less with an @import "custom-style" directive. The Rails Guide here recommends using @import (which is processed with SCSS/LESS) are over //=require (which is processed with Sprockets):

If you want to use multiple Sass files, you should generally use the Sass @import rule instead of these Sprockets directives. Using Sprockets directives all Sass files exist within their own scope, making variables or mixins only available within the document they were defined in.


This doesn't really answer your question, but is the only reason you are mixing sass and less to use twitter bootstrap? If you prefer to use just sass, there are some bootstrap gems where the authors convert the less to scss, like bootstrap-sass. Before I wasted too much time trying to juggle both in a project, I'd completely buy into one or the other, but that's just my opinion.