Skip to content

Commit

Permalink
Minify all nodes by default
Browse files Browse the repository at this point in the history
  • Loading branch information
siva-sundar committed Feb 19, 2018
1 parent d5ae5e5 commit 025f43a
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,36 +108,37 @@ function canTrimUnnecessaryWhiteSpace(value, config) {
}


const canTrimBlockStatementContent = function(node, config) {
function canTrimBlockStatementContent(node, config) {
// If a block or all the blocks is/are skiped (or) named as 'no-minify' then we need to preserve the whitespace.
let componentName = node.path.original;
if (config.components.indexOf(componentName) !== -1 || componentName === 'no-minify' || config.components === 'all') {
return false;
if (!(config.components.indexOf(componentName) !== -1 || componentName === 'no-minify' || config.components === 'all')) {
return true;
}
return true;
};
}

const canTrimElementNodeContent = function(node, config) {
function canTrimElementNodeContent(node, config) {
// If a element or all the element is/are skiped then we need to preserve the whitespace.
if (config.elements.indexOf(node.tag) !== -1 || config.elements === 'all') {
let elements = config.elements;
let tag = node.tag;
if (elements.indexOf(tag) !== -1 || elements === 'all' || tag === 'pre') {
return false;
}
let classAttributes = getElementAttribute(node, 'class');
return classAttributes ? canTrimUnnecessaryWhiteSpace(classAttributes, config) : true;
};
}

const assignDefaultValues = function(config) {
function assignDefaultValues(config) {
config = config || {};
let elements = config.elements || 'all';
let classes = config.classes || 'all';
let components = config.components || 'all';
let elements = config.elements || [];
let classes = config.classes || [];
let components = config.components || [];

return {
elements,
classes,
components
};
};
}

module.exports = {
stripWhiteSpace,
Expand Down

0 comments on commit 025f43a

Please sign in to comment.