vite-plugin-material-symbols 0.3.0-beta.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import esquery from "esquery";const isStringLiteral=(h)=>h.type==="Literal"&&"value"in h&&typeof h.value==="string",defaultUrlProvider=(h)=>`https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${h}`,makeSelector=(h)=>[`CallExpression[callee.name='jsx'][arguments.0.name='${h}']`,".arguments","Property[key.name='children'] Literal"].join(" > "),makeIconNamesParam=(h)=>{if(!h.size)return "";const i=[];for(const j of h.values())i.push(j);return `icon_names=${i.toSorted().join(",")}`},plugin=({component:h="Icon",getUrl:i=defaultUrlProvider}={})=>{const j=new Set();return {name:"material-symbols",enforce:"pre",moduleParsed:function({id:k,ast:l}){if(!l)return;const m=esquery.query(l,makeSelector(h)).filter(isStringLiteral);for(const {value:n}of m)this.debug({id:k,message:n}),j.add(n)},transformIndexHtml:(k)=>({html:k,tags:[{injectTo:"head",tag
|
|
1
|
+
import esquery from "esquery";const isStringLiteral=(h)=>h.type==="Literal"&&"value"in h&&typeof h.value==="string",defaultUrlProvider=(h)=>`https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${h}`,makeSelector=(h)=>[`CallExpression[callee.name='jsx'][arguments.0.name='${h}']`,".arguments","Property[key.name='children'] Literal"].join(" > "),makeIconNamesParam=(h)=>{if(!h.size)return "";const i=[];for(const j of h.values())i.push(j);return `icon_names=${i.toSorted().join(",")}`},plugin=({component:h="Icon",getUrl:i=defaultUrlProvider}={})=>{const j=new Set();return {name:"material-symbols",enforce:"pre",moduleParsed:function({id:k,ast:l}){if(!l)return;const m=esquery.query(l,makeSelector(h)).filter(isStringLiteral);for(const {value:n}of m)this.debug({id:k,message:n}),j.add(n)},transformIndexHtml:(k)=>({html:k,tags:[{injectTo:"head",tag:"link",attrs:{rel:"stylesheet",href:i(makeIconNamesParam(j))}}]})}};var src_default=plugin;export {src_default as default};
|