@devup-ui/webpack-plugin
Version:
Zero Config, Zero FOUC, Zero Runtime, CSS in JS Preprocessor
2 lines (1 loc) • 889 B
JavaScript
import{writeFile as s}from"node:fs/promises";import{basename as x,dirname as P,join as l,relative as p}from"node:path";import{codeExtract as k,exportClassMap as y,exportFileMap as C,exportSheet as L,getCss as O}from"@devup-ui/wasm";var S=function(u){let{watch:r,package:f,cssDir:i,sheetFile:h,classMapFile:d,fileMapFile:m,singleCss:g}=this.getOptions(),o=this.async(),a=this.resourcePath;try{let e=p(P(a),i).replaceAll("\\","/"),F=p(process.cwd(),a);if(!e.startsWith("./"))e=`./${e}`;let{code:w,css:D="",map:n,cssFile:c,updatedBaseStyle:v}=k(F,u.toString(),f,e,g,!1,!0),M=n?JSON.parse(n):null,t=[];if(v)t.push(s(l(i,"devup-ui.css"),O(null,!1),"utf-8"));if(c){let b=`${this.resourcePath} ${Date.now()}`;if(t.push(s(l(i,x(c)),r?`/* ${b} */`:D)),r)t.push(s(h,L()),s(d,y()),s(m,C()))}Promise.all(t).catch(console.error).finally(()=>o(null,w,M))}catch(e){o(e)}return},R=S;export{R as default};