Allow assets to be precompiled with Sprockets #456
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context #60.
This makes it possible to consume Mini Profiler's assets like any other assets in a Rails app. There is a new config option
assets_url
which isnil
by default but can be changed to a lambda that takes 3 arguments: asset_name (i.e.rack-mini-profiler.{js|css}
), version (which is the digest/version of MP assets), andenv
object, and the lambda should return a string that will be used as thesrc
for the asset. To preserve backward compatibility, the lambda is optional and Mini Profiler will fallback to the current behavior (serve assets from/mini-profiler-resources/*
) if no lambda is given or it returns a falsey value.For most Rails app, the following example will work fine:
I tested this change in a brand new Rails app and Discourse and in both apps
rake assets:precompile
generated MP assets in thepublic/assets
directory, and the assets loaded just fine from the/assets
route when I loaded a page in my browser.Thoughts on this @SamSaffron? Is this OK? Anything you would like me to change or test?