vite-plugin-material-symbols 0.1.0 → 0.2.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 CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## Version 0
4
4
 
5
+ ### v0.2.0
6
+
7
+ - The `placeholder` is now a complete URL of the Material Symbols CDN;
8
+ - New option `getUrl` is a function returning that URL based on
9
+ the `iconNamesParam` argument;
10
+ - All that allows to keep the HTML link this way:
11
+
12
+ ```html
13
+ <link rel="stylesheet" href="__MATERIAL_SYMBOLS__" />
14
+ ```
15
+
16
+ ### v0.1.1
17
+
18
+ - Fixed debugging message;
19
+
5
20
  ### v0.1.0
6
21
 
7
22
  - Two configuration options: `placeholder` and `component`.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # vite-plugin-material-symbols
2
2
 
3
- [![coverage](https://coveralls.io/repos/github/RobinTail/vite-plugin-material-symbols/badge.svg?branch=main)](https://coveralls.io/github/RobinTail/vite-plugin-material-symbols?branch=main)
3
+ [![coverage](https://coveralls.io/repos/github/RobinTail/vite-plugin-material-symbols/badge.svg?branch=main&)](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.
@@ -28,10 +28,7 @@ And the Material Symbols linked within `index.html` having `__MATERIAL_SYMBOLS__
28
28
  <!doctype html>
29
29
  <html lang="en">
30
30
  <head>
31
- <link
32
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&__MATERIAL_SYMBOLS__"
33
- rel="stylesheet"
34
- />
31
+ <link href="__MATERIAL_SYMBOLS__" rel="stylesheet" />
35
32
  </head>
36
33
  <body>
37
34
  <div id="root"></div>
@@ -54,6 +51,8 @@ export default defineConfig({
54
51
  // these are defaults:
55
52
  component: "Icon",
56
53
  placeholder: "__MATERIAL_SYMBOLS__",
54
+ getUrl: (iconNamesParam) =>
55
+ `https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${iconNamesParam}`,
57
56
  }),
58
57
  ],
59
58
  });
package/dist/index.d.ts CHANGED
@@ -1,9 +1,15 @@
1
1
  import type { Plugin } from "vite";
2
2
  type PluginOptions = {
3
+ /**
4
+ * Material Symbols CSS Provider. Default: outlined, no infill, 24px, weight 400
5
+ * @see https://fonts.google.com/icons?icon.set=Material+Symbols
6
+ * @default () => `https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined...&${iconNamesParam}`
7
+ * */
8
+ getUrl: (iconNamesParam: string) => string;
3
9
  /** @default __MATERIAL_SYMBOLS__ */
4
10
  placeholder: string;
5
11
  /** @default Icon */
6
12
  component: string;
7
13
  };
8
- declare const plugin: ({ placeholder, component, }?: Partial<PluginOptions>) => Plugin;
14
+ declare const plugin: ({ placeholder, component, getUrl, }?: Partial<PluginOptions>) => Plugin;
9
15
  export default plugin;
package/dist/index.js CHANGED
@@ -1 +1 @@
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};
1
+ import esquery from "esquery";const plugin=({placeholder:d="__MATERIAL_SYMBOLS__",component:e="Icon",getUrl:f=(h)=>`https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${h}`}={})=>{const g=new Set();return {name:"material-symbols",enforce:"pre",moduleParsed:function({id:h,ast:i}){if(!i)return;const j=esquery.query(i,`CallExpression[callee.name='jsx'][arguments.0.name='${e}'] > .arguments > Property[key.name='children'] Literal`);for(const {value:k}of j)if(typeof k==="string")this.debug({id:h,message:k}),g.add(k)},transformIndexHtml:(h)=>h.replace(d,f(g.size?`icon_names=${Array.from(g.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.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Selective loading of Material Symbols for production",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -16,6 +16,7 @@
16
16
  "build": "tsdown",
17
17
  "postbuild": "attw --pack --profile esm-only",
18
18
  "mdfix": "bunx --bun prettier *.md --write",
19
+ "version": "bun run version.ts",
19
20
  "prepublishOnly": "bun lint && bun test && bun run build"
20
21
  },
21
22
  "exports": {
@@ -24,7 +25,10 @@
24
25
  "default": "./dist/index.js"
25
26
  }
26
27
  },
27
- "files": ["dist", "*.md"],
28
+ "files": [
29
+ "dist",
30
+ "*.md"
31
+ ],
28
32
  "peerDependencies": {
29
33
  "vite": "^6.0.0"
30
34
  },
@@ -39,9 +43,11 @@
39
43
  "@types/esquery": "^1.5.4",
40
44
  "@types/react": "^18.3.12",
41
45
  "@types/react-dom": "^18.3.1",
46
+ "@types/semver": "^7.5.8",
42
47
  "@vitejs/plugin-react-swc": "^3.7.2",
43
48
  "react": "^18.3.1",
44
49
  "react-dom": "^18.3.1",
50
+ "semver": "^7.6.3",
45
51
  "tsdown": "^0.3.1",
46
52
  "typescript": "^5.7.2"
47
53
  }