st-bundle
Version:
CLI for watching and bundling SpringType projects.
21 lines (20 loc) • 774 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
function cssAutoImport(props) {
let contents = props.contents;
let extraHeaders = [];
for (const autoImport of props.stylesheet.autoImport) {
if (autoImport.file !== props.url) {
if (!autoImport.capture || (autoImport.capture && autoImport.capture['test'](props.url))) {
const relativePath = path.relative(path.dirname(props.url), autoImport.file);
extraHeaders.push(`@import ${JSON.stringify(relativePath)};`);
}
}
}
if (extraHeaders.length) {
contents = extraHeaders.join('\n') + '\n' + contents;
}
return contents;
}
exports.cssAutoImport = cssAutoImport;