@advdominion/lightningcss-loader
This commit is contained in:
22
packages/lightningcss-loader/index.js
Normal file
22
packages/lightningcss-loader/index.js
Normal 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;
|
||||
Reference in New Issue
Block a user