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
include_ember_* does not appear to honor asset prefix/fingerprint? #298
Comments
Appears to be the case in |
@thejchap thanks for opening this issue. There seems to be a few things in play here. For starters, I would expect the asset URLs to start with Second, if you're going to be serving the assets from a CDN, and/or are using a Rails-side prefix, you need to configure the addon accordingly: https://github.com/rondale-sc/ember-cli-rails-addon/#configuration Try something like this: // dashboard/ember-cli-build.js
function assetHostAndPrefix(environment) {
if (environment.match(/staging|production/i)) {
return 'https://d3dncadikrv0jv.cloudfront.net/' + environment + 'assets/';
}
}
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
'ember-cli-rails': {
prepend: assetHostAndPrefix(EmberApp.env()),
}
});
}; Could you give that a shot and report back with your results? |
@seanpdoyle Thanks for the reply No luck....it appears as if all the assets are being fingerprinted properly and put in the right place during And thanks for the link to the config...I'm not using the Very strange, because the Rails assets in |
@thejchap thanks for the additional information. I'll investigate further. As an alternative suggestion: Have you considered not setting Given that you're fingerprinting your assets, there won't ever be name collisions between staging and production assets, since the fingerprints take into account the contents of the files. The only way names would collide is if their contents were equivalent (in that case, they'd be identical and it wouldn't really be a "collision"). TL;DR you can safely serve / store / cache fingerprinted files from the same bucket |
@seanpdoyle thanks I'll let you know if I come across anything else. Re: not separating the assets into different folders - yeah, theoretically should be fine, and I will try this to see if it changes anything, but not a huge fan of the idea of having production and staging pointing to the same files....even given the fact that the file and its contents are the same |
Closes [thoughtbot/ember-cli-rails#298][#298]. [#298]: thoughtbot/ember-cli-rails#298
@thejchap could you try pulling down rondale-sc/ember-cli-rails-addon#22 // dashboard/package.json
{
"devDependencies": {
"ember-cli-rails-addon": "rondale-sc/ember-cli-rails-addon#sd-expose-prefix"
}
} and configuring the addon with your prefix: // dashboard/ember-cli-build.js
function emberCliRailsConfiguration(environment) {
if (environment.match(/staging|production/i)) {
return {
prepend: 'https://d3dncadikrv0jv.cloudfront.net/',
prefix: environment + 'assets/',
}
} else {
return {};
}
}
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
'ember-cli-rails': emberCliRailsConfiguration(EmberApp.env()),
});
}; If that works, I'll publish it as part of |
@seanpdoyle thanks! no luck unfortunately...the Also FYI, as far as I know, I am going to try wiping out all CDN configuration/prefix/asset_host/etc and see if they get linked to properly |
That might be part of the problem. Unless you're taking additional steps, Ember won't know how to treat
To that end, the addon doesn't currently fingerprint non-production-like builds (for the sake of non-fingerprinted URLs in development): Could you try not passing |
I'm very surprised by this. This line: prefix: environment + 'assets/', should ensure the prefix makes it's way into the URL. |
I have a hunch this is our culprit: ember-cli-rails/lib/ember_cli/sprockets.rb Lines 27 to 29 in 8eec101
def assets
["#{app.name}/assets/vendor", "#{app.name}/assets/#{ember_app_name}"]
end I'll investigate and push up a branch with a fix |
Right, however the behavior is still the same even when Thanks for all your help on this! This is an upgrade from 0.3.0 FWIW |
Trying to reproduce [thoughtbot/ember-cli-rails#298][#298]. [#298]: thoughtbot/ember-cli-rails#298
@thejchap I've tried to reproduce this bug here: https://github.com/seanpdoyle/ember-cli-rails-heroku-example/compare/sd-add-asset-tag-example Could you pull that down, make it work more like your production app in whatever way you need to? If you're able to reproduce the error, could you fork that repo and make a PR against that branch emphasizing the diff necessary to reproduce this bug? |
@seanpdoyle Here you go: Here is the app deployed on Heroku: Here are the |
FWIW, I'm seeing this too, and I'm not doing anything unusual with asset hosts, prefixes, etc. Everything fine on dev and test, but no fingerprint on production. |
Huh, now also seeing it after a delay on development. Assets come through at first, several minutes later they are 404. A rails server restart fixes this. May or may not be related to other issue. I'll investigate further. |
Looks like its consistently ~5 minutes after Rails server restart. I currently suspect this is unrelated, so splitting off into a new issue. |
Disregarding @botandrose's comments (that conversation is ongoing in #304), I think I know what's going on here. Rails isn't responsible for generating the fingerprints (EmberCLI handles that). When serving the EmberCLI-generated However, Rails still thinks the assets are named We currently handle this disconnect by using https://github.com/alexspeller/non-stupid-digest-assets to allow Rails' references to I'll do my best to add a failing test case to the test suite that covers this functionality. Once we have that, we can start working towards a solution. One possible solution is to force EmberCLI to generate a Rails-compatible manifest file, which we can monkey with and merge into Sprocket's version. Thanks for your patience in this. |
@seanpdoyle ah! got it. makes a lot of sense. i am happy to work on a PR if you'd like...if not lmk if there's anything else I can do to help. thanks for all your hard work on this....great tool |
@thejchap @botandrose could you two please try with the following: # Gemfile
gem "ember-cli-rails", github: "thoughtbot/ember-cli-rails", branch: "sd-manifest" // frontend/package.json
{
"devDependencies": {
"ember-cli-rails-addon": "rondale-sc/ember-cli-rails-addon#sd-manifest"
}
} Both files are experiments and won't land until we confirm they work. |
@seanpdoyle Booted my app in production, and the ember assets are coming through! Great work! |
@seanpdoyle nice! confirmed for me too |
@seanpdoyle FYI getting this locally in
|
@seanpdoyle yeah, looks like in development mode the generated script tags are empty |
Closes [thoughtbot/ember-cli-rails#298][#298]. For Rails to integrate Ember into the asset pipeline, EmberCLI must generate a Sprockets-compatible manifest file, which Rails will merge into its own Asset manifest. [#298]: thoughtbot/ember-cli-rails#298
Closes [thoughtbot/ember-cli-rails#298][#298]. For Rails to integrate Ember into the asset pipeline, EmberCLI must generate a Sprockets-compatible manifest file, which Rails will merge into its own Asset manifest. [#298]: thoughtbot/ember-cli-rails#298
@seanpdoyle which branch should i be on for the addon? |
@thejchap |
@thejchap this has been merged into Could you please try this out? |
FWIW @seanpdoyle master seems to have fixed my botched upgrade to 0.5.6 that had the same symptoms mentioned by @thejchap |
@seanpdoyle thanks sounds good. It did not resolve my issues, but I haven't yet had time to investigate/look into it in more detail. If I find out what's going on I'll open a new issue or reply here. Thanks for all your hard work! |
might be missing something...during heroku deploy...does this have to do with the custom
RAILS_ENV
? Still investigatingIn view
In application config (
RAILS_ENV='staging'
):The rendered script tags/style tags look like this (notice asset prefix and fingerprint are not present)....they are for all the rest of the rails assets (application.js/css, etc):
The text was updated successfully, but these errors were encountered: