@devup-ui/webpack-plugin
Version:
Zero Config, Zero FOUC, Zero Runtime, CSS in JS Preprocessor
41 lines (40 loc) • 1.01 kB
JavaScript
import { writeFile as r } from "node:fs/promises";
import { relative as d, dirname as P } from "node:path";
import { codeExtract as _, exportSheet as g, exportClassMap as x } from "@devup-ui/wasm";
const w = function(l) {
const {
watch: n,
package: p,
cssFile: o,
sheetFile: h,
classMapFile: u
} = this.getOptions(), e = this.async(), m = this.resourcePath;
try {
let t = d(P(this.resourcePath), o).replaceAll(
"\\",
"/"
);
t.startsWith("./") || (t = `./${t}`);
const { code: s, css: f, map: c } = _(
m,
l.toString(),
p,
t
), a = c ? JSON.parse(c) : null;
if (f && n) {
const i = `${this.resourcePath} ${Date.now()}`;
this._compiler && (this._compiler.__DEVUP_CACHE = i), Promise.all([
r(o, `/* ${i} */`),
r(h, g()),
r(u, x())
]).catch(console.error).finally(() => e(null, s, a));
return;
}
e(null, s, a);
} catch (t) {
e(t);
}
};
export {
w as default
};