GithubHelp home page GithubHelp logo

metaskills / less-rails Goto Github PK

View Code? Open in Web Editor NEW
339.0 16.0 134.0 182 KB

:-1: :train: Less.js For Rails

Home Page: http://github.com/metaskills/less-rails

License: MIT License

Ruby 95.54% Less 4.46%

less-rails's Introduction

The dynamic stylesheet language for the Rails 5+ asset pipeline.

This gem provides integration for Rails projects using the Less stylesheet language in the asset pipeline.

Build Status

Installing

Just bundle up less-rails in your Gemfile. This will pull in less as a runtime dependency too.

gem 'less-rails', '~> 4.0.0'

But be warned, less.rb relies on a JavaScript runtime gem too. Just like ExecJS, it will look for a gem that is appropriate to your system. Typically, this means you will need one of the following.

gem 'therubyracer' # Ruby
gem 'therubyrhino' # JRuby

Configuration

This gem was made for other gems to properly hook into one place to provide paths to the Less::Parser. For example, the less-rails-bootstrap project at http://github.com/metaskills/less-rails-bootstrap and each project should do the path configuration for you. If you need to, you can configure less-rails with additional paths. These paths have higher priority than those from your applications assets load paths.

MyProject::Application.configure do
  config.less.paths << "#{Rails.root}/lib/less/protractor/stylesheets"
  config.less.compress = true
end

About Compression

If config.assets.compress is set to true, we will set the config.less.compress to true as well. Less has real basic compression and it is recommended that you set the rails config.assets.css_compressor to something more stronger like :yui in your config/environments/production.rb file. Note, this requires the yui-compressor gem but does an excellent job of compressing assets.

Import Hooks

Any @import to a .less file will automatically declare that file as a sprockets dependency to the file importing it. This means that you can edit imported framework files and see changes reflected in the parent during development. So this:

@import "frameworks/bootstrap/mixins";

#leftnav { .border-radius(5px); }

Will end up acting as if you had done this below:

/*
 *= depend_on "frameworks/bootstrap/mixins.less"
*/

@import "frameworks/bootstrap/mixins";

#leftnav { .border-radius(5px); }

Passing parameters to less.rb

You can pass any parameters that the less.rb gem (which less-rails is based upon) supports by modifying Rails.application.config.less.raw. For example, less.rb uses lessc --relative-urls by default. This means that url('../ralative/paths.png') for @imported files will be modified according to .less file location. To return back to default lessc behavior, add these lines to config/initializers/assets.rb:

Rails.application.config.less.raw.relativeUrls = false

For more parameters supported by less.rb, please consult less.rb gem.

Helpers

When referencing assets use the following helpers in LESS.

asset-path(@relative-asset-path)  /* Returns a string to the asset. */
asset-path("rails.png")           /* Becomes: "/assets/rails.png" */

asset-url(@relative-asset-path)   /* Returns url reference to the asset. */
asset-url("rails.png")            /* Becomes: 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 and stylesheet. The following examples only show the -url variants since you get the idea of the -path ones above.

image-url("rails.png")            /* Becomes: url(/assets/rails.png) */
font-url("rails.ttf")             /* Becomes: url(/assets/rails.ttf) */
video-url("rails.mp4")            /* Becomes: url(/videos/rails.mp4) */
audio-url("rails.mp3")            /* Becomes: url(/audios/rails.mp3) */
javascript-url("rails.js")        /* Becomes: url(/assets/rails.js) */
stylesheet-url("rails.css")       /* Becomes: url(/assets/rails.css) */

Lastly, we provide a data url method for base64 encoding assets.

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

Please note that these helpers are only available server-side, and something like ERB templates should be used if client-side rendering is desired.

Generators

Installation of the gem will set your applications stylesheet engine to use Less. It is possible to have many gems that set the stylesheet engine, for instance the sass-rails and/or stylus gems. In this case, you can resolve the ambiguity by setting the stylesheet engine in your config/application.rb file like so. Doing so would mean all generated assets will be in the a fresh css.less template.

config.app_generators.stylesheet_engine :less

We have generators for both assets and scaffold in the less namespace. For instance the following would generate a blank app/assets/stylesheets/posts.css.less template.

$ rails generate less:assets posts

We also have a generator for rails scaffold CSS. Just like the Sass gem, we simply parse the scaffold.css in the default rails generator and save it as a scaffolds.css.less file. This is done automatically during other scaffold generator actions.

Contributing

This gem is fully tested from Rails 5.0 to Rails 6.0. We run our tests on Travis CI for officialy supported Rubies If you detect a problem, open up a github issue or fork the repo and help out. After you fork or clone the repository, the following commands will get you up and running on the test suite.

$ bundle
$ bundle exec appraisal install
$ bundle exec appraisal rake

We use the appraisal gem from Thoughtbot to help us generate the individual gemfiles for each Rails version and to run the tests locally against each generated Gemfile. The rake appraisal test command actually runs our test suite against all Rails versions in our Appraisal file. If you want to run the tests for a specific Rails version, use rake -T for a list. For example, the following command will run the tests for Rails 5.0 only.

$ bundle exec rake appraisal:rails50 test

Our current build status is: Build Status

License

Less::Rails is Copyright (c) 2011-2013 Ken Collins, [email protected] and is distributed under the MIT license.

less-rails's People

Contributors

anulman avatar bbenezech avatar brendon avatar cowboyd avatar dv avatar germanogmn1 avatar guilleiguaran avatar hisenb3rg avatar ilyapoz avatar kares avatar karzac avatar kentaro avatar leifcr avatar matthew342 avatar maxd avatar metaskills avatar michaelklishin avatar nicolasleger avatar pgib avatar rmm5t avatar simi avatar yalab avatar zhengjia 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

less-rails's Issues

Setting config.app_generators.stylesheet_engine :less has no effect

I'm using both less-rails (2.2.3) and sass-rails (3.2.5) in a rails 3.2.5 app in order to satisfy different dependencies in other gems. I want to use less for all freshly generated assets, but the sass-rails gem seems to take precedence. The readme for less-rails says that the ambiguity can be resolved by setting config.app_generators.stylesheet_engine :less in application.rb. I tried this with the following results:

$ rails g controller posts
# Generates app/assets/stylesheets/posts.css.scss

Overriding the stylesheet engine at the command line works fine, though:

$ rails g controller --stylesheet-engine=less posts
# Generates app/assets/stylesheets/posts.css.less

So the setting in application.rb seems to have no effect. What DID work was setting config.sass.preferred_syntax = :less in application.rb:

$ rails g controller posts
# Generates app/assets/stylesheets/posts.css.less - Hooray!

Not sure if this is just a documentation difference or an actual issue. I replicated it using a completely fresh rails app with the versions stated above.

rake assets:precompile grabs all .less files

application.css.less:

//= require widget

widget.css.less:

@import 'widget/variables'
@import 'widget/header'

app/assets/stylesheets/widget has variables.less and header.less.

The engine is processing the widget directory in alphabetical order, paying no attention to the application or widget manifests. If I remove the require or import statements entirely, the widget directory is still processed.

The problem arises if header.less uses variables.less, then it is undefined because the processing is in alphabetical order instead of manifest order; then I get an undefined variable error:

variable @xyz is undefined

I think this is in error, since only files included in the manifest somewhere should be included. I investigated by adding a puts to the default precompile proc:

 config.assets.precompile = [ Proc.new { |path| 
   puts path
   !File.extname(path).in?(['.js', '.css']) 
}, /(?:\/|\\|\A)application\.(css|js)$/ ]

The filename (path) passed to the proc is 'variables' not 'variables.less'. If I compare to a sass-rails configuration, I see that the equivalent 'variables.sass' file is passed to the precompile proc as 'variables.css' so it is NOT compiled, yielding the proper behavior.

I'm not exactly sure where to fix this, but I'm happy to submit a pull if you can point me in the right direction. My workaround for the moment is to add '' (filenames without extensions) to the precompile proc exclude list.

Add Rails Asset Pipeline helpers to Less

We need the ability to reference other assets (like images, video, etc.) from within a Less sheet. The Sass-rails folks accomplished this by adding helpers (like image-url(...), asset-url(..., ...), etc to the Sass langage. These functions delegate to the Rails path helpers to generate correct urls for various assets.

It may be a bit trickier for Less as Less is written in Javascript and less.rb is just wrapping it.

I think one possible solution would be to have the added Less helpers call back out to the wrapping Ruby code, which would need access to the Rails environment so it could then delegate on to the appropriate Rails-provided helpers.

Sorry if this is rambling - I'm between cups 1 and 2 of coffee, and haven't fully thought this through.

Support Less version 1.4.x

Could not find any mention on the website as to what less version less-rails uses.

From commit messages it appears its 1.3.3.

1.4.0 comes with the extends keyword which I need for my styles.

Is there a workaround to get 1.4.1 working with less-rails?

import-url not recognized

Hello.

I'm using rails 3.1.1 and less-rails 2.1.1.

In application.css.less I am loading another less file like so:
//= require layout

In layout.css.less, I'm trying to use image-url like so:
body {
padding-top: 50px;
background: image-url("body_background.png") repeat fixed 0 0 #d5d8db;
}

The background image is not showing up. When I view the css source on the client, I still see image-url("body_background.png") rather than url(/assets/body_background.png).

I definitely have the asset pipeline enabled, and have configured less explicitly as the stylesheet engine.

syntax errors fail silently

I don't get any errors if there is a syntax error in my less file. Is this intended behaviour or is there some configuration option to turn this on. I get semantic errors passed to my html such as that some mixin is not defined but if I just type some crap into the file then nothing is reported.

less.config not present in production

I dont need nor want the less-rails gem in production, but I need config.less.paths in order to make this work with less includes which i dont want to be processed by the asset-pipeline

# Gemfile
group :assets do
  gem 'less-rails'
end

#config/application.rb

MyProject::Application.configure do
  config.less.paths << "#{Rails.root}/lib/less/"
  config.less.compress = true
end

# becomes 

MyProject::Application.configure do
  if config.respond_to?(:less)
    config.less.paths << "#{Rails.root}/lib/less/"
    config.less.compress = true
 end
end

I need this workaround to get this to run

undefined method 'ends_with?'

I'm using the twitter-bootstrap-rails gem which depends on your gem and it's throwing an error as seen above (also seyhunak recommended to file it here issue #96)

15:04:14 server.1  | /Users/sylv3rblade/.rvm/gems/ruby-1.9.3-p125-perf@blog/gems/less-rails-2.1.6/lib/less/rails/railtie.rb:32:in 'block (2 levels) in ': undefined method 'ends_with?' for # (NoMethodError)
15:04:14 server.1  |    from /Users/sylv3rblade/.rvm/gems/ruby-1.9.3-p125-perf@blog/gems/less-rails-2.1.6/lib/less/rails/railtie.rb:32:in 'select'
15:04:14 server.1  |    from /Users/sylv3rblade/.rvm/gems/ruby-1.9.3-p125-perf@blog/gems/less-rails-2.1.6/lib/less/rails/railtie.rb:32:in 'block in '
15:04:14 server.1  |    from /Users/sylv3rblade/.rvm/gems/ruby-1.9.3-p125-perf@blog/gems/railties-3.2.2/lib/rails/initializable.rb:30:in 'instance_exec'

This issue popped up when I used the gem in Rails 3.2.x but it's not present in rails 3.1.x

railtie initializer conflict with other gem

Hi,

I'm the owner of the rolify gem. Some users have reported a strange bug regarding rolify's railtie that was not loaded properly at Rails boot (see EppO/rolify#156).
I've found out that this initializer block in less-rails causes this issue:

initializer 'less-rails.after.load_config_initializers', :after => :load_config_initializers, :group => :all do |app|
  app.assets.context_class.extend(LessContext)
  app.assets.context_class.less_config = app.config.less
end

If I remove this block or just the :after argument, it works fine. The code inside the block doesn't seem to be the issue because if I leave the block empty, it still fails.
I don't know if it's a less-rails or a Rails issue, I would go for the latter but I wanted to have your feedback first.

less-rails does not find *.less files in vendor/assets

I have the original bootstrap repo from twitter cloned as a submodule in my applications /vendor/assets/stylesheets/bootstrap folder. I also added gem 'less-rails to my Gemfile. Next I added a bootstrap.less file to /vendor/assets/stylesheets/ and in this file I @import the appropriate bootstrap modules.

In /app/assets/stylesheets/application.css I use *= require bootstrap.

When trying to precompile all assets using rake assets:precompile:all I get the following error:

couldn't find file 'bootstrap'
  (in /Users/[...]/app/assets/stylesheets/application.css:12)

I know this method works if I use the less gem instead of less-rails, but the reason I switched is because the less.rb gem actually uses an outdated less.js version, which won't compile bootstrap (see bootstrap#992).

Could you help me solve this issue? And does less-rails use a more recent version of less.js?

Mention therubyracer in README

Right now the README says:

 Just bundle up less-rails in your Gemfile.

This isn't complete. Some time in the past month apparently you need to add gem 'therubyracer' to your gemfile as well. Not sure the intention behind it but it's probably worth mentioning.

Make less-rails work on Windows, or use 'node' gem.

Currently requires 'therubyracer', and it does not work on Windows, despite the fact both 'node' and 'therubyracer' are installed.

  gem "execjs"
  gem 'therubyracer', :platforms => :ruby
  gem 'node'

gem "less-rails"
> gem list therubyracer
*** LOCAL GEMS ***

therubyracer (0.11.0beta1 x86-mingw32)

> gem list node
*** LOCAL GEMS ***

node (0.0.2)

Using gem 'therubyracer_for_windows'.
https://github.com/hiranpeiris/therubyracer_for_windows

>rails console
[WARNING] Please install gem 'therubyracer' to use Less.
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- v8 (LoadError)
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `block in require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/less-2.3.2/lib/less/java_script/v8_context.rb:2:in `<top (required)>'

Force Node usage under jruby

Can I tell less-rails to use system-node instead of therubyrhino? I only have therubyrhino as a dep in my development group, but when I run bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile it still isn't using Node. I see my Java process jump up to ~100-250% usage. I see Node blip at 100% for a couple seconds then disappears completely.

If I completely remove therubyrhino dep, I get this:

[WARNING] Please install gem 'therubyrhino' to use Less under JRuby.
[WARNING] Please install gem 'therubyrhino' to use Less under JRuby.
rake aborted!
no such file to load -- rhino
org/jruby/RubyKernel.java:1027:in `require'
org/jruby/RubyKernel.java:1027:in `require'
org/jruby/RubyKernel.java:1027:in `require'
o

Using less (2.2.2) and less-rails (2.2.6).

possible issue with nested imports?

I'm probably doing something wrong, but I appreciate any help you can give me. Bascially, the problem is that when I directly import the less-rails-bootstrap less files into a *.css.less file, everything works fine. But, when I import those files into a *.less file, then import that file into a *.css.less file, I run into file not found issues. I've uploaded a repo that reproduces the behavior at: https://github.com/stuffihavemade/less-rails-test . The first commit shows the working behavior, and the second commit shows the parser breaking. Again, thanks for any help!

style does not update if partial change

I have some partial files under partials folder, the style.css.less import all the partials. Whenever I make change to any partial file, I have to re-save style.css.less (by add a blank line) to have changes in partial files.

Cannot get compression to work

I cannot get compression to work. In development mode nothing happens. In production mode I get NoMethodError.

config.less.compress = true

undefined method `less' for #<Rails::Application::Configuration:0x0000000252aee8>
NoMethodError

I think Less should obey the app.config.assets.compress setting. Which is true per default in production mode. Maybe something similar to sass-rails:

initializer :setup_compression, :group => :all do |app|
  if app.config.assets.compress
    # Use sass's css_compressor
    app.config.assets.css_compressor = CssCompressor.new
  end
end

What do you think?

Should Asset Helpers Work With Digests?

Spawed from ticket #3 which mentioned that given this.

.myimage() {
  background-image: image-url("less_framework/less.png");
}
#container {
  .myimage();
}

Compiles with rake assets:precompile to this content #container{background-image:url(/assets/less_framework/less.png);}. The question is should there be a digest in that asset url? Here is what is output to the assets directory.

  • less_framework/less-ef9b99c1df7d13853cb626bdf3f1f269.png
  • less_framework/less.png

Will need to look at sass-rails and see if it does this too. Feedback appreciated.

Recompile imported .less files after modification

Update:

I have an application.less file that @imports various .less files, (e.g. sites.less and chart.less) from assets/stylesheets. When I edit chart.less and refresh application.css, the changes in chart.less are reflected in the compiled CSS file, but this was not the case for sites.less. This led me to a false conclusion that adding config.less.env = 'development' to an environment file fixed my issue, when I was actually testing on the chart.less file that was refreshing properly anyway.

My actual issue was omitting the //= depend_on "sites.less" statement. Though I did not have a depend_on charts.less statement either, which led me to weird false conclusions. @import should have added the depend_on in the background, but for some imports it did not.

The old suggestion below is rubbish:

I think it's worth pointing out (perhaps under "Import Hooks" in the readme?) that the contents of @import'ed .less files will be cached. To make sure your imported files are recompiled after they have been modified, tell LESS that we're in development mode via config/environments/development.rb:

config.less.env = 'development';

one level of indirection needed in order to get @imports to operate properly

If you have a file like the following file, let's call it main.css.less:

@import "variables.less"
@import "a.less";
@import "b.less"; 
@import "c.less"; 

Any variables imported through the variables.less file will not be accessible to a, b, or c. To get this to function, you need to add 1 level of indirection, that is (for example) - renamed main.css.less to imported.less, and create a new main.css.less that does something like:

@import "imported.less"

While these two scenarios are semantically equivalent only the second scenario functions without errors.

@import vs. @require

Usually you have just one stylesheet in your Rails project. But sometimes there are certain pages in the project that have a very complex design and it would be a waste to load those styles on every other page. So you make the layout load application.css and a controller specific stylesheet. Now you want to use twitter-bootstrap-rails in your project so you put @import "twitter/bootstrap/bootstrap"; in your application.css.less. But you also want to use some variables and mixins from Bootstrap in your controller specific stylesheets too. You would need to @import "twitter/bootstrap/bootstrap"; which would add all the styles from Bootstrap again but you already have them in your application.css.

Long story short: What abou a @require statement that, in contrast to @import, would just load the referenced file for compilation but would not add any content to the compiled file? Does it make sense?

Helpers not available in assets:precompile

I have found that I am getting an error when running assets:precompile stating the helpers are not available.

error evaluating function image-url``

Everything runs fine in development mode with dynamic compilation of stylesheets, but not on precompile. Any suggestions as to why they are not available?

rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/adam/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/adam/.rvm/gems/ruby-1.9.2-p290/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
error evaluating function `image-url`
  (in /Users/adam/Development/backchat-marketing/app/assets/stylesheets/homepage.css.less)
at /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-2.0.8/lib/less/js/lib/less/parser.js:336:38
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-2.0.8/lib/less/parser.rb:88:in `block in to_css'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-2.0.8/lib/less/parser.rb:13:in `block in calljs'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-2.0.8/lib/less/parser.rb:27:in `block in lock'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-2.0.8/lib/less/parser.rb:25:in `lock'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-2.0.8/lib/less/parser.rb:12:in `calljs'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-2.0.8/lib/less/parser.rb:87:in `to_css'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-rails-2.1.2/lib/less/rails/template_handlers.rb:17:in `evaluate'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/context.rb:175:in `block in evaluate'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in `evaluate'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:171:in `build_dependency_context_and_body'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:135:in `dependency_context'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:194:in `build_dependencies_paths_and_assets'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:141:in `dependency_paths'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:61:in `mtime'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/asset.rb:58:in `block in encode_with'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/asset.rb:57:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/asset.rb:57:in `encode_with'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:43:in `encode_with'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/caching.rb:52:in `cache_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/index.rb:67:in `block in build_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/index.rb:76:in `memoize'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/index.rb:65:in `build_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/trail.rb:102:in `find_asset_in_path'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:101:in `find_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/index.rb:48:in `find_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:110:in `[]'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-rails-2.1.2/lib/less/rails/import_processor.rb:13:in `block in evaluate'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-rails-2.1.2/lib/less/rails/import_processor.rb:12:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/less-rails-2.1.2/lib/less/rails/import_processor.rb:12:in `evaluate'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/context.rb:175:in `block in evaluate'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in `evaluate'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:171:in `build_dependency_context_and_body'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:135:in `dependency_context'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:194:in `build_dependencies_paths_and_assets'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:141:in `dependency_paths'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:61:in `mtime'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/asset.rb:58:in `block in encode_with'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/asset.rb:57:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/asset.rb:57:in `encode_with'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:43:in `encode_with'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/caching.rb:52:in `cache_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/index.rb:67:in `block in build_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/index.rb:76:in `memoize'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/index.rb:65:in `build_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/trail.rb:102:in `find_asset_in_path'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:101:in `find_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/index.rb:48:in `find_asset'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/sprockets/static_compiler.rb:20:in `block in compile'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:151:in `block in each_logical_path'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:139:in `block (2 levels) in each_file'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:129:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:129:in `each_entry'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:137:in `block in each_file'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:136:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:136:in `each_file'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.0.3/lib/sprockets/base.rb:149:in `each_logical_path'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/sprockets/static_compiler.rb:18:in `compile'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/sprockets/assets.rake:52:in `internal_precompile'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/sprockets/assets.rake:66:in `block (3 levels) in <top (required)>'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/sprockets/assets.rake:56:in `block (3 levels) in <top (required)>'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/Users/adam/.rvm/rubies/ruby-1.9.2-p290/bi...]
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils.rb:80:in `ruby'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/sprockets/assets.rake:9:in `ruby_rake_task'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/sprockets/assets.rake:17:in `invoke_or_reboot_rake_task'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/adam/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'

@import "file.css" from asset pipeline

Hi,

maybe it's too late and I don't see the obvious:

I have two projects that use

 less-rails (2.3.2)
      less (~> 2.3.1)

However, one project includes @import "morris.core.css"; during assets:precompile, the other leaves it and thus tries to fetch it in production mode.

The files are named the same (application.less), production config is same, and I tried to clear cache at both files with no success. Which one is the "normal" behavior? Any idea why the projects could differ?

Help is greatly appreciated :)

Is there any way to declare a compilation dependency but NOT include it in the output?

I'd like to split my css into separate application.css and vendor.css files with the application.css file containing just our styles and the vendor.css containing just the vendor (e.g. bootstrap) styles in order to allow the vendor css to be cached for longer periods of time by the browser. Continuous deployment of our site means that the application.css file's fingerprint is changing on a nearly daily basis. In reality, though, it's generally just the application styles that are changing. Vendor style changes are much more infrequent and could theoretically be cached.

Unfortunately, I can't figure out any way to get my less files to compile without @importing the vendor files (which have mixins and variables we use). What I'd like to do is tell the less compiler that it should depend on certain other files for compilation, but NOT include them in the output. Is that an option?

error while compiling less file

I just upgraded from less-rails '2.3.3' to '2.4.0'. After that I can't compile given file In my rails project. I recive this error while rake assets:precompile

rake aborted!
Unrecognised input
  (in /project/path/app/assets/stylesheets/bootstrap_and_overrides.css.less)
...

Downgrade to 2.3.3 fixes the problem.

The file that won't compile (it comes from other gem):

@import "twitter/bootstrap/bootstrap";
@import "twitter/bootstrap/responsive";

// Set the correct sprite paths
@iconSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings");
@iconWhiteSpritePath: asset-path("twitter/bootstrap/glyphicons-halflings-white");

// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
// Note: If you use asset_path() here, your compiled bootstrap_and_overrides.css will not
//       have the proper paths. So for now we use the absolute path.
@fontAwesomeEotPath: asset-path("fontawesome-webfont.eot");
@fontAwesomeEotPath_iefix: asset-path("fontawesome-webfont.eot#iefix");
@fontAwesomeWoffPath: asset-path("fontawesome-webfont.woff");
@fontAwesomeTtfPath: asset-path("fontawesome-webfont.ttf");
@fontAwesomeSvgPath: asset-path("fontawesome-webfont.svg");

// Font Awesome
@import "fontawesome";

// Glyphicons
//@import "twitter/bootstrap/sprites.less";

// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation
//
// Example:
// @linkColor: #ff0000;

Full error:

rake aborted!
Unrecognised input
  (in /project/path/app/assets/stylesheets/bootstrap_and_overrides.css.less)
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/parser.rb:74:in `block (2 levels) in parse'
at finish (/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/js/lib/less/parser.js:475:21)
at tree.importVisitor.run (/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/js/lib/less/import-visitor.js:25:22)
at Parser.parser.parse (/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/js/lib/less/parser.js:484:22)
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/parser.rb:64:in `block in parse'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/java_script/v8_context.rb:90:in `block in do_lock'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/java_script/v8_context.rb:88:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/java_script/v8_context.rb:88:in `Locker'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/java_script/v8_context.rb:88:in `do_lock'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/java_script/v8_context.rb:60:in `lock'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/java_script/v8_context.rb:30:in `exec'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/java_script.rb:26:in `exec'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-2.4.0/lib/less/parser.rb:63:in `parse'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/less-rails-2.4.0/lib/less/rails/template_handlers.rb:18:in `evaluate'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:105:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:16:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/actionpack-3.2.10/lib/sprockets/static_compiler.rb:19:in `block in compile'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/actionpack-3.2.10/lib/sprockets/static_compiler.rb:18:in `compile'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/actionpack-3.2.10/lib/sprockets/assets.rake:56:in `internal_precompile'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/actionpack-3.2.10/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/actionpack-3.2.10/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/usr/local/rvm/rubies/ruby-1.9.3-p385/bin/...]
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/actionpack-3.2.10/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/actionpack-3.2.10/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/usr/local/rvm/gems/ruby-1.9.3-p385@global/gems/actionpack-3.2.10/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p385/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p385/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

@import should handle .css.less files

With Sass, the following statements in application.css.scss seem to be equivalent:

@import "test";
//= require test

Having either one or both will include the test.css.scss file once. That's awesome!

With LESS (application.css.less), this doesn't work: The @import statement will only include a test.less file, whereas the //= require statement will only include a test.css.less file. (Unless I'm missing something?)

I'm thinking that on Rails, LESS's @import should work with .css.less files. What do you think?


Version specs:

less (2.0.9)
less-rails (2.1.6)
sass (3.1.15)
sass-rails (3.2.4)
sprockets (2.1.2)
rails (3.2.1)

the gem before less-rails was not initialized before the files in config/initializers

This is a wierd bug found in my project. When I put Carrierwave before less-rails, then it loads before config/initializers, this is what normal rails expected.But when move the Carrierwave after the less-rails, it didnt load before initializers.

I reproduce it in a sample app https://github.com/raykin/bug_of_init_process. For simplicity, Kaminari which replace Carrierwave was used to reproduce the bug. You can easily follow the readme to reproduce it.

It looks like concerned with less-rails, but I didnt found wierd stuff when I look around source of less-rails. I'm not sure if it's a bug of bundler or rails

asset-path Not being invoked

I've been having some issues with asset-path or any derivative (image-url, etc) not working. I've tried naming my files as .css.less or just .less using @import or *=require. I'm using jruby 1.9.3 and my application is setup as an engine.

Compilation Errors When Using 'application.css.less'

Given the following stylesheets:

app/assets/stylesheets/application.less.css

@import "mixins.css.less";
@import "main.css.less";

app/assets/stylesheets/mixins.css.less

.ninja { display: none; }

app/assets/stylesheets/main.less.css

#me { .ninja } 

A compilation error .ninja is undefined when running rake assets:precompile. However running lessc application.css.less works. A full sample is here: http://api.cld.me/0k0I3N450n0y2f0U0b1d/download/demo.zip.

Issue using mix

Using the following code to mix two colours:

@base: #ffdc52;
@add: #195742;
.colour{
    color: mix(@base, @add);
}

getting the following outout:

Less::ParseError: error evaluating function `mix`: Cannot read property 'value' of undefined

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Less::ParseError on @import directives

Definitely, the web is littered with various messages about this error. I think I have eliminated those possibilities, and I wonder if you might have any insight. Here's the deal:

Rails 4.0.0beta1 (I'll put Gemfile.lock below for your pleasure), all gems fully up to date.

I've gone through all of the instructions I could find, regarding setting Sprockets load paths as well as the less load paths. Finally, in an act of exasperation I flattened the contents of twitter/bootstrap into my app/assets/stylesheets directory, and I continue to get the same error:

Action Controller_ Exception caught

Here is what I have done to work around it... I think it's HIGHLY hacky and I hope that you've a good suggestion.

For example. In the case of the error shown above. The line importing normalize.less looks like this:

bootstrap less next_meeting-1

Notice that lines 1 and 2 refer to .css files. I renamed those files in the directory, to filename.css.less. When I change normalize.less in the same way, the fun comes back... but only for one line.

Action Controller_ Exception caught-2

bootstrap less next_meeting-2

Is there a configuration setting that will enable the parser to recognize a different set of file extensions? Or something else I have missed?

Thanks for your great work.

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'coffee-rails', '~> 4.0.0.beta1'
  gem 'uglifier', '>= 1.0.3'
  # gem 'bootstrap3-wip-rails', '0.1.3' # path: '/Users/tyler/src/dev/bootstrap3-wip-rails'
  # gem 'bootstrap3-wip-rails', github: 'tylergannon/bootstrap3-wip-rails'
  gem 'twitter_bootstrap_form_for', path: '/Users/tyler/src/dev/twitter_bootstrap_form_for'
  gem 'underscore-rails'
end
gem 'therubyracer'
gem 'less-rails'

Excerpt from Gemfile.lock:

less (2.3.2)
  commonjs (~> 0.2.6)
less-rails (2.3.3)
  actionpack (>= 3.1)
  less (~> 2.3.1)
libv8 (3.11.8.17)

precompile does not precompile .css.less files

In my config/application.rb file, I'm adding files to config.assets.precompile, like so:

config.assets.precompile << 'tables.css.less'
config.assets.precompile << 'autosuggest.css'

When I run rake assets:precompile, the autosuggest.css file gets precompiled (shows up in public/assets), but tables.css does not.

Is this the expected behavior?

Because yui-compressor requires POpen it doesn't support jruby.

I noticed that you listed jruby support but have a dependency on the yui-compressor gem. Unfortunately, jruby doesn't support fork which is what POpen uses to do the compression. Due to this I wanted to make sure others are aware that this will not work under jruby.

Cannot call method 'charAt' of undefined

I'm getting the above error (in /Users/burtondav/sites/requestsys/app/assets/stylesheets/bootstrap_and_overrides.css.less)

The same error is noted in the issue list for less.js

@media print doesn't work

Hi,

I have to report that in v2.3.3 @media print does not work. While precompiling it fails due to:

Invalid CSS after "...edia print and ": expected media expression (e.g. (min-device-width: 800px)), was "print,screen an..."

best regards

Is there a comprehensive explanation of how to set up assets?

I've looked through the issues and people seem to be having the same problems . I'm relatively new to Rails so perhaps the solution is here but I can't find it.

I have 8 Less files in my assets/stylesheets directory and I would like one to contain mixins to be used by the other 7 files.
Originally, I put the mixins.css.less file in it's own directory and the other 7 files were all named .css.less. Each file contained *@import "/minxins/mixins.less"** and application.css contained "require_directory ."

This worked but the mixin file was included 7 times.

I tried @import'ing all the files in application.css.less but now I need to clear the cache every time I make a change to one of the less files.

What is the correct way to do this? I think this is a standard configuration.
Thanks.

Compatibility with 2.0.0-rc2

Had an interesting wait while trying to hit my homepage with 2.0.0-rc2 and less-rails 2.2.6 with sprockets 2.2.2:

Started GET "/" for 127.0.0.1 at 2013-02-14 03:10:22 +0800
Processing by LandingController#index as HTML
  Rendered landing/index.html.erb within layouts/application (0.6ms)
Compiled print/bootstrap_and_overrides.css  (488093ms)  (pid 77058)
Compiled print/print.css  (0ms)  (pid 77058)
Compiled print/schedule.print.css  (0ms)  (pid 77058)
Compiled print/style_light.css  (0ms)  (pid 77058)
Compiled application-print.css  (488190ms)  (pid 77058)
Completed 200 OK in 494140ms (Views: 494138.9ms | ActiveRecord: 0.0ms)

Takes about 8 minutes to compile over 2.0 latest RC but works almost immediate in 1.9.3.

Less files not recursively imported

In main.css.less I have the line: @import "global"
Inside global.less I have the line: @import "variables" (and several other similar lines)

For some reason, if I try to use any of my variables inside of main.css.less it will throw a variable undefined error.

Why are less assets not recursively loading like they should?

Integrate with Sprockets

@import directives should integrate with Sprockets. Right now, your imported partials must be .less files, and not .css.less.

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.