@advdominion/lightningcss-loader

This commit is contained in:
2026-01-21 15:13:48 +04:00
parent 9131e220d2
commit ca88f622d1
4 changed files with 95 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
const lightningcssLoader = (source, sourceMap) => {
const { implementation, ...options } = this.getOptions();
const callback = this.async();
if (typeof implementation !== 'function') {
throw new TypeError(
`[lightningcss-loader]: The "implementation" option is required and must provide "transform" function of the LightningCSS`,
);
}
const { code, map } = implementation({
filename: this.resourcePath,
code: Buffer.from(source),
sourceMap: this.sourceMap,
inputSourceMap: this.sourceMap && sourceMap ? JSON.stringify(sourceMap) : undefined,
...options,
});
callback(undefined, code.toString(), map && JSON.parse(map.toString()));
}
export default lightningcssLoader;