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.

43 lines
944 B
JavaScript

3 years ago
"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 = function (_options = {}) {
return {
postcssPlugin: pluginName,
Once: (root, { result }) => {
let discoveredImports = new Set();
let { icssImports } = icssUtils.extractICSS(root, 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;