Skip to content

Commit

Permalink
construct cacheKey based on minifier config
Browse files Browse the repository at this point in the history
  • Loading branch information
siva-sundar committed Jan 2, 2018
1 parent b23073a commit d89c2e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 3 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
/* eslint-env node */
'use strict';
let objectHash = require('object-hash');

module.exports = {
name: 'ember-hbs-minifier',

_getMinifierOptions() {
return (this.parent && this.parent.options) || (this.app && this.app.options) || {};
},

_setupPreprocessorRegistry(app) {
let registry = app.registry;
let options = this._getMinifierOptions();
let options = app.options || {};
let config = options['ember-hbs-minifier'] || {};

let HbsMinifierPlugin = require('./hbs-minifier-plugin')(config.skip || {});
registry.add('htmlbars-ast-plugin', {
name: 'hbs-minifier-plugin',
plugin: HbsMinifierPlugin,
baseDir() { return __dirname; },
cacheKey() { return 'ember-hbs-minifier'; }
cacheKey() { return `ember-hbs-minifier-${objectHash.MD5(config)}`; }
});
},

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"ember-welcome-page": "^2.0.2",
"eslint-config-simplabs": "0.2.2",
"jest": "^21.2.0",
"loader.js": "^4.1.0"
"loader.js": "^4.1.0",
"object-hash": "1.2.0"

},
"engines": {
"node": ">= 4"
Expand Down

0 comments on commit d89c2e1

Please sign in to comment.