You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
This module is derived from: css-loader (https://github.com/webpack-contrib/css-loader)
|
|
|
|
(c) JS Foundation and other contributors
|
|
|
|
|
|
|
|
Modifications by:
|
|
|
|
(c) 2019, Sven Slootweg <admin@cryto.net>
|
|
|
|
|
|
|
|
Licensed under:
|
|
|
|
MIT (https://opensource.org/licenses/MIT)
|
|
|
|
*/
|
|
|
|
|
|
|
|
const icssUtils = require("icss-utils");
|
|
|
|
const loaderUtils = require("loader-utils");
|
|
|
|
|
|
|
|
const pluginName = 'postcss-icss-find-imports';
|
|
|
|
|
|
|
|
module.exports = (_options = {}) => {
|
|
|
|
return {
|
|
|
|
postcssPlugin: pluginName,
|
|
|
|
Once(css, { result }) {
|
|
|
|
let discoveredImports = new Set();
|
|
|
|
|
|
|
|
let { icssImports } = icssUtils.extractICSS(css, false);
|
|
|
|
|
|
|
|
for (let importUrl of Object.keys(icssImports)) {
|
|
|
|
discoveredImports.add(loaderUtils.parseString(importUrl));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let url of discoveredImports) {
|
|
|
|
result.messages.push({
|
|
|
|
pluginName: pluginName,
|
|
|
|
type: "import",
|
|
|
|
url: url
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.postcss = true;
|