-
Notifications
You must be signed in to change notification settings - Fork 157
Description
Hi Les, it turns out the quirks of the assets precompile stage on Heroku can make things a little tricky if you are using HandlebarsAssets to customize the compiler. I thought I'd share the findings, and maybe you could include a note in the docs to make life easier for others.
This is not a bug of any sort, just sharing info gained.
The issue is while in "development" putting the following in an initialiser or config
HandlebarsAssets::Config.options = { data: true }
works perfectly fine, but they won't compile that way on Heroku if you aren't precompiling prior to pushing, because Heroku's compile step runs prior, and usually most people have
config.assets.initialize_on_precompile = false
and HandlebarsAssets is usually in the "assets" group in Gemfile, so not available in Production
My solution is to add a form of the following:
if "assets" == ENV["RAILS_GROUPS"] || ["development", "test"].include?(ENV["RAILS_ENV"])
HandlebarsAssets::Config.options = { data: true }
end
Now assets:precompile under every scenario I've encountered compiles with the custom options. Hope this is useful.