broccoli-asset-rev icon indicating copy to clipboard operation
broccoli-asset-rev copied to clipboard

Support adding to the default fingerprinted extensions

Open aprescott opened this issue 8 years ago • 2 comments

  • ember-cli 2.13.0
  • broccoli-asset-rev 2.5.0

It looks like setting extensions: ["foo"] will override and replace and the default extensions configuration. There doesn't seem to be a configurable way of extending that list of default extensions.


When using fingerprintOptions via ember-cli, I noticed that "svg" isn't part of the default extension options, which was causing some discrepancies with url('/assets/images/.../foo.svg') vs url('/images/.../foo.svg') in CSS.

To fix that, I tried setting this configuration:

var app = new EmberApp(defaults, {
  fingerprint: {
    enabled: true,
    exclude: ['fonts'],
    extensions: ["svg"]
  },

  /* ... */
});

However, looking at the code, that seems to override and remove the default options, since options.extensions takes precedence over defaults.extensions.

Also, setting extensions: ["svg"] caused my app to not build correctly, for reasons I can't quite explain.

It would be great to be able to add to the default extensions list.

I worked around that manually like so:

var defaultFingerprintExtensions = require('broccoli-asset-rev/lib/default-options').extensions;

/* ... */

var app = new EmberApp(defaults, {
  fingerprint: {
    enabled: true,
    exclude: ['fonts'],
    extensions: defaultFingerprintExtensions.concat(["svg"])
  },

  /* ... */
});

aprescott avatar Jul 07 '17 15:07 aprescott

@aprescott I stumbled into the missing svg extension yesterday as well and observed interesting behaviour as well. How does your build process behave when passing in a complete new list of extensions? E.g.

extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map', 'svg']

melv-n avatar Jul 11 '17 09:07 melv-n

@mirague yep, that works fine, since it's the same as concating against the default. I wanted to avoid hard-coding the current set of defaults, which is why my work-around above uses concat.

aprescott avatar Jul 11 '17 15:07 aprescott