Automatically re-export imports

pull/2/head
Sven Slootweg 4 years ago
parent deac5044ca
commit 92bcf4fdca

@ -14,13 +14,14 @@ Licensed under:
const postcss = require("postcss");
const icssUtils = require("icss-utils");
const loaderUtils = require("loader-utils");
const { validateOptions, required, isFunction } = require("validatem");
const { validateOptions, required, isFunction, isBoolean } = require("validatem");
const pluginName = 'postcss-icss-parser';
module.exports = postcss.plugin(pluginName, (options = {}) => {
validateOptions([options], {
keyReplacer: [ required, isFunction ]
keyReplacer: [ required, isFunction ],
autoExportImports: [ isBoolean ]
});
return function process(css, result) {
@ -43,6 +44,17 @@ module.exports = postcss.plugin(pluginName, (options = {}) => {
type: 'icss-import',
item: { url, localKey, remoteKey, newKey, index },
});
if (options.autoExportImports !== false) {
result.messages.push({
pluginName: pluginName,
type: "icss-export",
item: {
name: localKey,
value: newKey
}
});
}
}
}

Loading…
Cancel
Save