问题
I've followed the very thorough instructions below to add sprockets/asset pipeline to a legacy Rails 2.3.18 application I'm working on:
http://jaredonline.github.io/blog/2012/05/16/sprockets-2-with-rails-2-dot-3/
I have one outstanding issue -- in my vendor/assets/stylesheets/bootstrap
dir, I have copied all of the .scss files from the sass-bootstrap gem.
When I run the rake task provided in the above URL, rake assets:precompile
, it errors out with this error: https://github.com/thomas-mcdonald/bootstrap-sass/issues/378
The issue is that sprockets is trying to compile some partial .scss files, which should just be compiled into the main application.css file.
Since I don't have the ability to change the config.assets.precompile
Rails configuration in 2.3.18, how do you recommend I tell sprockets to ignore compiling these partial .scss files individually?
回答1:
@joris provided good insight, but I had already figured it out by the time you replied!
Inside assets.rake#internal_precompile
, change the last line to:
manifest.compile [ Proc.new { |path| !%w(.js .css).include?(File.extname(path)) }, /application.(css|js)$/ ]
Found this answer a little ways down on this page: http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets
回答2:
Looking at the code in Sprockets 2, I see manifest.compile accepts an argument. Browsing the code it looks like the argument is a kind of filter you can use on your assets. I didn't try or test anything with it, but maybe it gives you a starting point.
来源:https://stackoverflow.com/questions/17730155/sprockets-asset-pipeline-in-rails-2-3