UNPKG

1.39 kBJavaScriptView Raw
1var path = require('path');
2
3var defaults = require('./lib/default-options');
4
5module.exports = {
6 name: 'broccoli-asset-rev',
7 initializeOptions: function() {
8 var defaultOptions = {
9 enabled: this.app.env === 'production',
10 exclude: defaults.exclude,
11 extensions: defaults.extensions,
12 prepend: defaults.prepend,
13 replaceExtensions: defaults.replaceExtensions
14 };
15
16 // Allow simply setting { fingerprint: false } as a shortcut option to disable
17 if (this.app.options.fingerprint === false) {
18 this.options = this.app.options.fingerprint = { enabled: false };
19 } else {
20 this.options = this.app.options.fingerprint = this.app.options.fingerprint || {};
21 }
22
23 for (var option in defaultOptions) {
24 if (!this.options.hasOwnProperty(option)) {
25 this.options[option] = defaultOptions[option];
26 }
27 }
28 },
29 postprocessTree: function (type, tree) {
30 if (type === 'all' && this.options.enabled) {
31 tree = require('./lib/asset-rev')(tree, this.options);
32 }
33
34 return tree;
35 },
36 included: function (app) {
37 this.app = app;
38 this.initializeOptions();
39 },
40 treeFor: function() {},
41
42 // ember-cli-fastboot uses the presence of this flag to give a
43 // helpful error if you're using an older version of this addon that
44 // doesn't know how to rewrite the fastboot manifest.
45 supportsFastboot: true
46};