question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compatibility with broccoli-asset-rev functionality (asset fingerprinting, assetMap.json manifest)

See original GitHub issue

In the past it was mentioned that Embroider eliminates the need for broccoli-asset-rev: https://github.com/ember-cli/broccoli-asset-rev/issues/65#issuecomment-535089537

Perhaps I’ve lost something along the way with our embroider configuration but it seems like broccoli-asset-rev still fills two roles in our deploy pipeline:

  • Static asset revisioning + rewriting (bitmaps, svgs, mp3s, etc.)
  • Asset manifest production (dist/assetMap.json)

Static asset revisioning

Is there any way to replicate the behaviour of static assets (eg. in public/) getting checksum filenames?

Asset manifest production (assetMap.json)

The latter is somewhat more trivial and, with a little manual work, can be statically generated from the files on disk post-build but I’m wondering if Embroider considers this a first-class feature.

In our apps we often don’t use the index.html generated by the build process but rather generate the html server-side ourselves, injecting the correct script tags referencing the latest bundle revision. With this setup we rely on the assetMap.json generated by broccoli-asset-rev to allow us to look up the right asset (mapping development build filenames to production asset filenames, eg. appname.jsappname-1A2B3C.js).

To try reach feature parity with this in Embroider land, we configure webpack to limit the initial bundle count to 1 and give it a special name (eg. appname.[chunkhash].js, such that it’s distinguishable from the runtime chunks pulled in by @embroider/router). This works nicely and we can even use a webpack plugin to generate a similar asset manifest but this doesn’t work for the vendor bundles as they’re synthesised outside of webpack.

Is this asset manifest still a useful concept with Embroider and if so could it warrant being emitted as a build artefact? (Even as an opt-in)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
ef4commented, Nov 25, 2021

We are working on a standardized solution here: https://github.com/emberjs/rfcs/pull/763

3reactions
mydeacommented, Nov 25, 2021

It is still not really clear to me (as somebody who is not really experienced with Webpack, which I guess probably applies to a lot of Ember devs) how I am supposed to migrate my existing, previously auto-fingerprinted code to Embroider/Webpack.

It would be great if there would be a kind of “how to” documentation in how to do that - maybe somebody who knows how these things work can help out there? Some concrete examples:

  1. We have a bunch of images, e.g. in a template:
<img src="/assets/img/my-image.png" />

That used to be fingerprinted, but now aren’t. So if I update the image without changing the file name, it will not be reflected.

  1. We have some static (generated) JSON files we use for translation:
export const jsonMap = {
  de: '/assets/translations/de.json',
  it: '/assets/translations/it.json'
}

// somewhere else...
fetch(jsonMap[locale]);

The JSON files also used to be auto-fingerprinted (when adding .json to the fingerprint extensions), which also doesn’t happen anymore either.

I’m happy to update some configuration or do some manual stuff, but I honestly don’t really know where to start 😬

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolving fingerprinted assets using generateAssetMap
For production, I have Broccoli generate an assets map file assets/assetMap.json by including the following in my ember-cli-build.js file:
Read more >
broccoli-asset-rev - Ember Observer
Broccoli plugin to add fingerprint checksums to your files and update the source to reflect the new filenames. Turns <script src="assets/appname ...
Read more >
The Asset Pipeline - Ruby on Rails Guides
The third feature of the asset pipeline is it allows coding assets via a ... The require_tree directive in a CSS manifest works...
Read more >
ember-l10n - npm
By default, ember-l10n assumes your locale files are fingerprinted in production ... Note: If you experience issues with multiple assetMap.json files being ...
Read more >
Ember.js Lazy Assets: Fingerprinting & loading static/dynamic ...
Some or many of these resources can be functionality centric, means they are ... The assetMap.json file itself is not fingerprinted.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found