Last active
May 29, 2019 11:59
-
-
Save parndt/11381872 to your computer and use it in GitHub Desktop.
Asset precompilation from an Engine's initializer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### RAILS 4.1 | |
# Doesn't work, due to the error: | |
# Asset filtered out and will not be served: add | |
# `Rails.application.config.assets.precompile += %w( refinery/refinery.css )` | |
# to `config/initializers/assets.rb` and restart your server | |
class MyEngine < Rails::Engine | |
# set the manifests and assets to be precompiled | |
initializer "refinery.assets.precompile" do |app| | |
app.config.assets.precompile += %w( | |
refinery/* | |
refinery/icons/* | |
wymeditor/lang/* | |
wymeditor/skins/refinery/* | |
wymeditor/skins/refinery/**/* | |
modernizr-min.js | |
admin.js | |
) | |
end | |
end | |
# Works: | |
class MyEngine < Rails::Engine | |
# set the manifests and assets to be precompiled | |
config.to_prepare do | |
Rails.application.config.assets.precompile += %w( | |
refinery/* | |
refinery/icons/* | |
wymeditor/lang/* | |
wymeditor/skins/refinery/* | |
wymeditor/skins/refinery/**/* | |
modernizr-min.js | |
admin.js | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. I should point out that you should only include the manifest if you're using a manifest to load the rest of the stylesheets/javascripts. I didn't get it right the first because I used
/*
instead of including the manifest explicitly. That resulted in loading everything with no regards to the load order specified in the manifest.