Skip to content

Commit 6c38c38

Browse files
committed
Tidy up
1 parent 98e5277 commit 6c38c38

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,17 @@ const walkRules = (css, callback) => {
111111
});
112112
};
113113

114+
const addExports = (css, aliases) => {
115+
const { icssImports, icssExports } = extractICSS(css);
116+
const exports = Object.assign({}, icssExports, aliases);
117+
css.prepend(createICSSRules(icssImports, exports));
118+
};
119+
114120
module.exports = postcss.plugin(plugin, (options = {}) => css => {
115121
const generateScopedName =
116122
options.generateScopedName ||
117123
genericNames("[name]__[local]---[hash:base64:5]");
118124
const input = (css && css.source && css.source.input) || {};
119-
const { icssImports, icssExports } = extractICSS(css);
120125
const aliases = {};
121126
const getAlias = name => {
122127
const alias = generateScopedName(name, input.from, input.css);
@@ -134,7 +139,5 @@ module.exports = postcss.plugin(plugin, (options = {}) => css => {
134139
throw rule.error(e.message);
135140
}
136141
});
137-
css.prepend(
138-
createICSSRules(icssImports, Object.assign({}, icssExports, aliases))
139-
);
142+
addExports(css, aliases);
140143
});

0 commit comments

Comments
 (0)