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

Support adding to the default fingerprinted extensions #117

Open aprescott opened 6 years ago

aprescott commented 6 years ago

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"])
  },

  /* ... */
});
mirague commented 6 years ago

@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']
aprescott commented 6 years ago

@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.