Skip to content
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

Fingerprints should be generated after autoprefixing files #38

Closed
mirague opened this issue Sep 8, 2017 · 4 comments
Closed

Fingerprints should be generated after autoprefixing files #38

mirague opened this issue Sep 8, 2017 · 4 comments

Comments

@mirague
Copy link

mirague commented Sep 8, 2017

It would seem the generated fingerprint on .css files is generated -before- the file's contents are autoprefixed. See this diff, comparing the original vendor.css file (without autoprefixing) to the one post autoprefixing:
https://www.diffchecker.com/xk5ell28

Both of them have the following fingerprint:

<link rel="stylesheet" href="/assets/vendor-71a8f7f0ec9ee74bd7700d99a5f0b69d.css" integrity="sha256-Wfg3oOX5yWiadWxDW9FY1hyYG5JAGkQ4UUeaf7bTXmg= sha512-ykM/yDR0Yy/sRRHm2hNUUQtV/MgRLeX1RYc3wNVLRpIB47kbD5C4goWlbBK9077Y7hTM3XGcNtpBevekWsoHoQ==">

This is an issue when:

  • the file is cached as vendor-71a8f7f0ec9ee74bd7700d99a5f0b69d.css (without autoprefixing)
  • the contents change due to autoprefixing (diff), the filename remains the same.
  • the generated integrity hashes -do- change and suddenly the user's cached version conflicts and is not loaded:

image

Versions
Ember: 2.15.1
broccoli-asset-rev:
ember-cli-autoprefixer: 0.8.0

@mirague
Copy link
Author

mirague commented Sep 8, 2017

The underlying cause may be similar to that of ember-cli/broccoli-asset-rev#118, which was addressed by introducing a two-stage pipeline approach: ember-cli/broccoli-asset-rev#121

@mirague mirague changed the title Not working well with fingerprinting Fingerprints should be generated after autoprefixing the CSS files Sep 8, 2017
@mirague mirague changed the title Fingerprints should be generated after autoprefixing the CSS files Fingerprints should be generated after autoprefixing files Sep 8, 2017
@cbrevdev
Copy link
Contributor

cbrevdev commented Sep 8, 2017

Oh nice find! ember-cli-autoprefixer is indeed being run after the fingerprinting stage.

DEBUG="*:Fingerprint,*:AutoprefixerFilter,*:SRIHashAssets" ember build --prod

Shows:

broccoli-filter:Fingerprint
broccoli-persistent-filter:AutoprefixerFilter
broccoli-caching-writer:SRIHashAssets

with mismatched asset fingerprint:

MD5 (dist/assets/vendor-eaf3a09c2cb3eef1a98fd76408256234.css) = 25f52e8d963d263cc305c82b2ba54368

We can influence the order by modifying package.json to indicate that autoprefix must occur before broccoli-asset-rev:

"ember-addon": {
    "configPath": "tests/dummy/config",
    "before": "broccoli-asset-rev"
},

resulting in an adjusted build order:

broccoli-persistent-filter:AutoprefixerFilter
broccoli-filter:Fingerprint
broccoli-caching-writer:SRIHashAssets

and corrected asset fingerprint:

MD5 (dist/assets/vendor-25f52e8d963d263cc305c82b2ba54368.css) = 25f52e8d963d263cc305c82b2ba54368

I'll put together a PR.

cbrevdev added a commit to RevolutionDisplay/ember-cli-autoprefixer that referenced this issue Sep 8, 2017
cbrevdev added a commit to RevolutionDisplay/ember-cli-autoprefixer that referenced this issue Sep 8, 2017
@mirague
Copy link
Author

mirague commented Sep 9, 2017

Hey @cbrevdev, thanks for the quick reply and PR! I had no idea about the existence of the "before" mechanic - I'm happy you did!

cbrevdev added a commit to RevolutionDisplay/ember-cli-autoprefixer that referenced this issue Sep 16, 2017
kimroen pushed a commit that referenced this issue Sep 19, 2017
@kimroen
Copy link
Owner

kimroen commented Sep 19, 2017

Thank you very much for this, both of you. This has been fixed in #39 and released as version 0.8.1 now! 🎉

@kimroen kimroen closed this as completed Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants