vite-plugin-material-symbols 0.0.2 → 0.1.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/CHANGELOG.md +11 -0
- package/README.md +9 -2
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/package.json +8 -2
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# vite-plugin-material-symbols
|
|
2
2
|
|
|
3
|
-
[](https://coveralls.io/github/RobinTail/vite-plugin-material-symbols)
|
|
3
|
+
[](https://coveralls.io/github/RobinTail/vite-plugin-material-symbols?branch=main)
|
|
4
4
|
|
|
5
5
|
The plugin determines which Material Symbols are used in JSX `<Icon>` tags and substitutes this list in `index.html`
|
|
6
6
|
for selective download from Google CDN, thus reducing the volume of the font downloaded by the user.
|
|
@@ -48,7 +48,14 @@ import react from "@vitejs/plugin-react-swc";
|
|
|
48
48
|
import materialSymbols from "vite-plugin-material-symbols";
|
|
49
49
|
|
|
50
50
|
export default defineConfig({
|
|
51
|
-
plugins: [
|
|
51
|
+
plugins: [
|
|
52
|
+
react(),
|
|
53
|
+
materialSymbols({
|
|
54
|
+
// these are defaults:
|
|
55
|
+
component: "Icon",
|
|
56
|
+
placeholder: "__MATERIAL_SYMBOLS__",
|
|
57
|
+
}),
|
|
58
|
+
],
|
|
52
59
|
});
|
|
53
60
|
```
|
|
54
61
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
|
-
|
|
2
|
+
type PluginOptions = {
|
|
3
|
+
/** @default __MATERIAL_SYMBOLS__ */
|
|
4
|
+
placeholder: string;
|
|
5
|
+
/** @default Icon */
|
|
6
|
+
component: string;
|
|
7
|
+
};
|
|
8
|
+
declare const plugin: ({ placeholder, component, }?: Partial<PluginOptions>) => Plugin;
|
|
3
9
|
export default plugin;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import esquery from "esquery";const plugin=()=>{const
|
|
1
|
+
import esquery from "esquery";const plugin=({placeholder:d="__MATERIAL_SYMBOLS__",component:e="Icon"}={})=>{const f=new Set();return {name:"material-symbols",enforce:"pre",moduleParsed:function({id:g,ast:h}){if(!h)return;const i=esquery.query(h,`CallExpression[callee.name='jsx'][arguments.0.name='${e}'] > .arguments > Property[key.name='children'] Literal`);this.debug({id:g,message:"value"});for(const {value:j}of i)if(typeof j==="string")f.add(j)},transformIndexHtml:(g)=>g.replace(d,f.size?`icon_names=${Array.from(f.values()).toSorted().join(",")}`:"")}};var src_default=plugin;export {src_default as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-material-symbols",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Selective loading of Material Symbols for production",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"prebuild": "tsc --noEmit",
|
|
16
16
|
"build": "tsdown",
|
|
17
17
|
"postbuild": "attw --pack --profile esm-only",
|
|
18
|
-
"mdfix": "bunx --bun prettier *.md --write"
|
|
18
|
+
"mdfix": "bunx --bun prettier *.md --write",
|
|
19
|
+
"prepublishOnly": "bun lint && bun test && bun run build"
|
|
19
20
|
},
|
|
20
21
|
"exports": {
|
|
21
22
|
".": {
|
|
@@ -36,6 +37,11 @@
|
|
|
36
37
|
"@tsconfig/bun": "^1.0.7",
|
|
37
38
|
"@types/bun": "^1.1.14",
|
|
38
39
|
"@types/esquery": "^1.5.4",
|
|
40
|
+
"@types/react": "^18.3.12",
|
|
41
|
+
"@types/react-dom": "^18.3.1",
|
|
42
|
+
"@vitejs/plugin-react-swc": "^3.7.2",
|
|
43
|
+
"react": "^18.3.1",
|
|
44
|
+
"react-dom": "^18.3.1",
|
|
39
45
|
"tsdown": "^0.3.1",
|
|
40
46
|
"typescript": "^5.7.2"
|
|
41
47
|
}
|