rails asset pipeline production precompile

I have a directory projName/vendor/assets/bootstrap/css/ I am in production mode. production.rb contains: config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/ when I run rake assets:precompile I get projName/public/assets/css/ but I want projName/public/assets/bootstrap/css/ I do not understand why the bootstrap directory is not there. Actually all the top level directories under vendor/assets and app/assets are missing in public assets/

Answers


Compiled assets are written to the location specified in config.assets.prefix. By default, this is the public/assets directory.

To understand this you have to first understand what precompiling is and does. Let me explain

When you run (a rake task)

rake assets:precompile

it will create a public folder inside your application folder which will compile all your asset manifests (ie. your application.css and application.js)

How exactly does this happen ?? -> Rails comes bundled with a rake task which will compile all this. That rake task is what is shown above.

Compiled assets are written to the location specified in config.assets.prefix. By default, this is the public/assets directory.

The default matcher for compiling files includes application.js, application.css and all non-JS/CSS files (this will include all image assets automatically) from app/assets folders including your gems.

And thats exactly what that regex means (to include everything in your app/assets folder), you can also explicitly provide it as shown in the answer above.

Hope this helped.

Here are few links for your reference

http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

http://dennisreimann.de/blog/precompiling-rails-assets-for-development/


What does that regex mean? If you want to precompile everything, try this.

config.assets.precompile = ['*.js', '*.css']

Actually, if you want to precompile everything, try this:

def precompile?(path)
  %w(app lib vendor).each do |asset_root|
    assets_path = Rails.root.join(asset_root, 'assets').to_path
    return true if path.starts_with?(assets_path)
  end
  false
end

# Precompile all assets under app/assets (unless they start with _)
Rails.application.config.assets.precompile << proc do |name, path|
  starts_with_underscore = name.split('/').last.starts_with?('_')
  unless starts_with_underscore
    path = Rails.application.assets.resolve(name).to_path unless path # Rails 4 passes path; Rails 3 doesn't
    precompile?(path)
  end
end

(Based on the code in the Rails Guide.)


Need Your Help

XSLT 2.0 template matching - strip all attributes which are not in the desired namespace

xml xslt xpath xml-namespaces xml-attribute

I have an XML with differently namespaced attributes - it's basicly a kind of extended XHTML. I want to dump all the non-xhtml namespaced attributes.

Can I control register allocation in g++?

optimization gcc g++ inline cpu-registers

I have highly optimized piece of C++ and making even small changes in places far from hot spots can hit performance as much as 20%. After deeper investigation it turned out to be (probably) slightly

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.