@lynx-js/template-webpack-plugin
Version:
Simplifies creation of Lynx template files to serve your webpack bundles
27 lines • 993 B
JavaScript
import { cssToAst } from './ast.js';
import { debundleCSS } from './debundle.js';
export function cssChunksToMap(cssChunks, plugins, enableCSSSelector) {
const cssMap = cssChunks
.reduce((cssMap, css) => {
debundleCSS(css, cssMap, enableCSSSelector);
return cssMap;
}, new Map());
return {
cssMap: Object.fromEntries(Array.from(cssMap.entries()).map(([cssId, content]) => {
const [root] = cssToAst(content.join('\n'), plugins);
root.forEach(rule => {
if (rule.type === 'ImportRule') {
// For example: '/981029' -> '981029'
rule.href = rule.href.replace('/', '');
}
});
return [cssId, root];
})),
cssSource: Object.fromEntries(Array.from(cssMap.keys()).map(cssId => [
cssId,
`/cssId/${cssId}.css`,
])),
contentMap: cssMap,
};
}
//# sourceMappingURL=cssChunksToMap.js.map