ember-cli / broccoli-asset-rev

Broccoli plugin to add fingerprint checksums and CDN URLs to your assets
MIT License
87 stars 84 forks source link

Using customHash has returned to prepending multiple times again #99

Open typeoneerror opened 7 years ago

typeoneerror commented 7 years ago

(note: closed https://github.com/rickharrison/broccoli-asset-rewrite/issues/43 in favor of this issue)

Updated to latest and assets are now getting "assets" three times when using customHash and prepend.

in: <img src="assets/icons/stripe.svg"> out: <img src="http://localhost:4200/assets/assets/assets/icons/stripe.svg">

  var fingerprintOptions = {
    enabled: true,
    extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map', 'svg'],
    generateAssetMap: true,
    prepend: 'http://localhost:4200/',
    customHash: null,
    generateAssetMap: false
  };

Looks specific to customHash again (removing that fixes again) and may be related to https://github.com/rickharrison/broccoli-asset-rev/issues/87

typeoneerror commented 7 years ago

FYI, the assetMap generated when generateAssetMap: true looks correct, so this may be an ember-cli issue.

bichotll commented 7 years ago

The same over here :/

bichotll commented 7 years ago

Hi @typeoneerror, any solution or at least workaround regarding this? ;)

I needed for a commercial project, I'm afraid :/

typeoneerror commented 7 years ago

@bichotll I didn't have any issues with production builds, it was only when I had customHash: null and generateAssetMap: false set in development build that it fails like this. So workaround is to just not use customHash at all locally and deal with the hash output on the dist files.

rickharrison commented 7 years ago

A failing test case would be really helpful in debugging this!

grayt0r commented 7 years ago

I ran into this issue and in the process of trying to create a failing test case realised, for me at least, that's it's actually caused by an open issue on broccoli-asset-rewrite: https://github.com/rickharrison/broccoli-asset-rewrite/issues/39.

We reference the same relative image URL a few times in our CSS and each of those references appears to be rewritten multiple times, resulting in assets/ appearing in the path multiple times. This only happens when customHash: null is specified as if the file is fingerprinted then after the first rewrite the path will no longer match the fingerprint regex.

Happy to provide a failing test for the broccoli-asset-rewrite repo, but believe the test in the proposed PR to fix the issue linked above covers the same scenario.

rickharrison commented 7 years ago

Yes, that would be great if you had a failing test case over there.