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.
icssify/src/postcss/postcss-icss-find-imports.js

39 lines
915 B
JavaScript

"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 postcss = require("postcss");
const icssUtils = require("icss-utils");
const loaderUtils = require("loader-utils");
const pluginName = 'postcss-icss-find-imports';
module.exports = postcss.plugin(pluginName, (_options = {}) => {
return function process(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
});
}
};
});