house9

random code and what not

ember-cli broccoli fingerprinting

| Comments

ember-cli uses broccoli for asset compilation and fingerprinting of asset file names.

When the environment is production, the addon will automatically fingerprint your js, css, png, jpg, and gif assets …

No fingerprinting occurs in the development environment. These are great defaults, but what if you have a staging environment and want to fingerprint those assets? You can override the fingerprint setting when the ember application is created.

1
2
3
4
5
var app = new EmberApp({
  fingerprint: {
    enabled: true
  }
});

Now all environments will fingerprint assets, but we really don’t want that in development. Since the ember application has not booted up yet we do not have access to the configuration object directly – lucky for us it is available on the process object before the ember application is created.

1
2
3
4
5
6
7
8
// Brocfile.js
var emberEnvironment = process.env.EMBER_ENV;
var fingerprint = (emberEnvironment === 'production' || emberEnvironment === 'staging');
var app = new EmberApp({
  fingerprint: {
    enabled: fingerprint
  }
});

Comments