You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
812 B
2 lines
812 B
"use strict";var _compiler=require("@hap-toolkit/compiler");class Css2jsonPlugin{constructor(s){this.options=s}apply(s){s.hooks.emit.tapAsync("Css2jsonPlugin",(s,t)=>{for(const t in s.assets)if(t.match(/css\.json$/)){const e=s.assets[t]._source.children.filter(s=>s._value),o=e.length;e.map((s,e)=>{this.css2Json({code:s._value,filePath:t},t=>{let c="";0===e?(c='{"list":['+t,c+=e===o-1?"]}":","):(c=t,c+=e<o-1?",":"]}"),s._value=c})})}t()}),s.hooks.afterEmit.tapAsync("Css2jsonPlugin",(s,t)=>{for(const t in s.assets)t.match(/css\.json$/)&&(s.assets[t]._source.children=[]);t()})}css2Json(s,t){const e=String(s.code).match(/\[(.*)\]/);let o={};const{parsed:c}=(0,_compiler.parseStyle)(s);let n=c;if(e&&e[1]){o[e[1]]=n}else o=n;t&&t(o)}}module.exports=Css2jsonPlugin;
|
|
//# sourceMappingURL=css2json-plugin.js.map
|
|
|