Skip to content

Commit c1a6a03

Browse files
committed
Merge pull request #90 from juwara0/exportDefaultOptions
Updated default settings to be in one place and allow for usage in external app/addon
2 parents 9d9adae + cc1adb7 commit c1a6a03

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ var assetNode = new AssetRev(node, {
6363
- `ignore` - Default: `[]` - An array of strings. If a filename contains any item in the ignore array, the contents of the file will not be processed for fingerprinting.
6464
- `annotation` - Default: null. A human-readable description for this plugin instance.
6565

66+
## Default settings
67+
The default [settings](https://github.com/rickharrison/broccoli-asset-rev/blob/master/lib/default-options.js) are available if needed in your application or addon via:
68+
`var broccoliAssetRevDefaults = require( 'broccoli-asset-rev/lib/default-options' );`
69+
6670
## Ember CLI addon usage
6771

6872
```js

index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
var path = require('path');
22

33
var assetRev = require('./lib/asset-rev');
4+
var defaults = require('./lib/default-options');
45

56
module.exports = {
67
name: 'broccoli-asset-rev',
78
initializeOptions: function() {
89
var defaultOptions = {
910
enabled: this.app.env === 'production',
10-
exclude: [],
11-
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'],
12-
prepend: '',
13-
replaceExtensions: ['html', 'css', 'js']
14-
}
11+
exclude: defaults.exclude,
12+
extensions: defaults.extensions,
13+
prepend: defaults.prepend,
14+
replaceExtensions: defaults.replaceExtensions
15+
};
1516

1617
// Allow simply setting { fingerprint: false } as a shortcut option to disable
1718
if (this.app.options.fingerprint === false) {

lib/asset-rev.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var defaults = require('./default-options');
12
var Fingerprint = require('./fingerprint');
23
var UseRev = require('broccoli-asset-rewrite');
34

@@ -11,15 +12,15 @@ function AssetRev(inputTree, options) {
1112
this.assetMap = {};
1213
this.inputTree = inputTree;
1314
this.customHash = options.customHash;
14-
this.extensions = options.extensions || ['js', 'css', 'png', 'jpg', 'gif', 'map'];
15-
this.replaceExtensions = options.replaceExtensions || ['html', 'css', 'js'];
16-
this.exclude = options.exclude || [];
17-
this.fingerprintAssetMap = options.fingerprintAssetMap || false;
15+
this.extensions = options.extensions || defaults.extensions;
16+
this.replaceExtensions = options.replaceExtensions || defaults.replaceExtensions;
17+
this.exclude = options.exclude || defaults.exclude;
18+
this.fingerprintAssetMap = options.fingerprintAssetMap || defaults.fingerprintAssetMap;
1819
this.generateAssetMap = options.generateAssetMap;
1920
this.generateRailsManifest = options.generateRailsManifest;
20-
this.assetMapPath = options.assetMapPath || '';
21-
this.railsManifestPath = options.railsManifestPath || '';
22-
this.prepend = options.prepend || '';
21+
this.assetMapPath = options.assetMapPath || defaults.assetMapPath;
22+
this.railsManifestPath = options.railsManifestPath || defaults.railsManifestPath;
23+
this.prepend = options.prepend || defaults.prepend;
2324
this.ignore = options.ignore;
2425
this.description = options.description;
2526

lib/default-options.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
module.exports = {
3+
assetMapPath: '',
4+
exclude: [],
5+
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'],
6+
fingerprintAssetMap: false,
7+
prepend: '',
8+
railsManifestPath: '',
9+
replaceExtensions: ['html', 'css', 'js']
10+
};

0 commit comments

Comments
 (0)