Skip to content

Commit

Permalink
support for addon/engine
Browse files Browse the repository at this point in the history
  • Loading branch information
siva-sundar committed Oct 4, 2017
1 parent 53dde0b commit 93b3586
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
16 changes: 16 additions & 0 deletions .hbs-minifyrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

module.exports = {
/*
Possible values
* 'all' => all nodes will be considered as whitelisted, hence whitespace will be preserved for the same.
* ['div', 'span'] => whitespace will be preserved for div and span.
* [] => An empty array is specified to strip all the whitespaces.
*/
whiteList: {
elementNodes: ['pre'],
elementClassNames: 'all',
components: 'all',
partials: 'all'
}
}
26 changes: 12 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ module.exports = {
name: 'ember-hbs-minifier',

setupPreprocessorRegistry(type, registry) {
if (type === 'parent') {
let config;
try {
let path = this.isDevelopingAddon() ? `${this.project.root}/tests/dummy` : this.project.root;
config = require(`${path}/.hbs-minifyrc.js`);
} catch (error) {
throw error;
}
let HbsMinifierPlugin = require('./hbs-minifier-plugin')(config.whiteList);
registry.add('htmlbars-ast-plugin', {
name: 'hbs-minifier-plugin',
plugin: HbsMinifierPlugin,
baseDir() { return __dirname; }
});
let config;
try {
let path = this.isDevelopingAddon() ? `${this.parent.root}/tests/dummy` : this.parent.root;
config = require(`${path}/.hbs-minifyrc.js`);
} catch (error) {
throw error;
}
let HbsMinifierPlugin = require('./hbs-minifier-plugin')(config.whiteList);
registry.add('htmlbars-ast-plugin', {
name: 'hbs-minifier-plugin',
plugin: HbsMinifierPlugin,
baseDir() { return __dirname; }
});
}
};

0 comments on commit 93b3586

Please sign in to comment.