-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot remove asset dependency path in Rails 5 #314
Comments
For anyone searching here's the thing: In your Rails 5 initializer you don't have all the paths populated yet, so we want to do this rejection after the initialization is complete. Rails.application.config.after_initialize do
Rails.application.config.assets.paths.reject! do |path|
path.include? 'rails-assets-bootstrap'
end
end However this is a little simplistic, as noted in another issue (#282) this will reject Here's an example that lets you set an array of gem names to reject, it includes the gem version in the final check to safely reject specific gems only: Rails.application.config.after_initialize do
# add the gem names you wish to reject to the below array
excluded_gem_names = ['rails-assets-bootstrap']
excluded_gem_full_names = Gem::Specification.select { |g| excluded_gem_names.include? g.name }.flat_map { |a| a.full_name }
Rails.application.config.assets.paths.reject! do |path|
excluded_gem_full_names.any? { |gem_name| path.include? gem_name }
end
end |
I couldn't get the above to work in Rails 5.2, but using the Rails.application.config.to_prepare do
Rails.configuration.assets.paths.reject! do |path|
path =~ /rails-assets-bootstrap-[0-9]/
end
end |
Hi, I created this issue since #132 is locked.
I have the exact same issue of the link above but the mentioned workaround does not appear to be working on Rails 5 (beta 3). The assets path is empty while trying to access from an initializer. Do you know any workaround for this?
The text was updated successfully, but these errors were encountered: