Skip to content

Commit

Permalink
clear data after transformBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
gjbkz committed Jul 3, 2017
1 parent 4aa7e6b commit efed26b
Show file tree
Hide file tree
Showing 3 changed files with 408 additions and 7 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const RADIX = 62;
function plugin(params = {}) {

const filter = createFilter(params.include, params.exclude);
const labeler = new Labeler('classNames');
const classLabeler = new Labeler('classNames');
const globalRoot = postcss.root();

async function transform (source, id) {
Expand All @@ -24,7 +24,7 @@ function plugin(params = {}) {
let replaceCount = 0;
rule.selector = selector.replace(/\.([^,\s]+)/g, (match, className) => {
replaceCount++;
const label = labeler.label(`${id}${className}`);
const label = classLabeler.label(`${id}${className}`);
const newClassName = `_${new BigNumber(label).toString(RADIX)}`;
labeled[className] = newClassName;
return `.${newClassName}`;
Expand All @@ -51,6 +51,8 @@ function plugin(params = {}) {
.map((node) => {
return encodeString(`${node}`, labeler);
});
classLabeler.clear();
globalRoot.nodes.splice(0, globalRoot.nodes.length);
return `${source}\n${generageCode(labeler.items, encodedRules, params.debug)}`;
}

Expand Down
Loading

0 comments on commit efed26b

Please sign in to comment.