vite-plugin-material-symbols 0.6.0 → 0.7.1
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 +13 -0
- package/README.md +15 -5
- package/dist/index.d.ts +14 -2
- package/dist/index.js +1 -1
- package/package.json +9 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## Version 0
|
|
4
4
|
|
|
5
|
+
### v0.7.1
|
|
6
|
+
|
|
7
|
+
- Added the following configuration options for flexibility:
|
|
8
|
+
- `moduleIdRegex` — the regex to match module IDs that should be processed for finding icon names;
|
|
9
|
+
- `jsxNodeRegex` — The regex to match JSX nodes that should be processed in parsed AST;
|
|
10
|
+
- The option `component` now also can be a regex to match multiple component names.
|
|
11
|
+
|
|
12
|
+
### v0.7.0
|
|
13
|
+
|
|
14
|
+
- Supporting Vite 8;
|
|
15
|
+
- Drop Vite 6 and 7 support;
|
|
16
|
+
- Drop Node 20 support.
|
|
17
|
+
|
|
5
18
|
### v0.6.0
|
|
6
19
|
|
|
7
20
|
- Supporting Vite 7.
|
package/README.md
CHANGED
|
@@ -18,8 +18,10 @@ the font downloaded by the user.
|
|
|
18
18
|
|
|
19
19
|
## Requirements
|
|
20
20
|
|
|
21
|
-
- Node.js `^
|
|
22
|
-
-
|
|
21
|
+
- Node.js `^22 || ^24`;
|
|
22
|
+
- use the plugin version 0.6 for Node 20;
|
|
23
|
+
- Vite `^8`
|
|
24
|
+
- use the plugin version 0.6 for Vite 6 and 7;
|
|
23
25
|
|
|
24
26
|
## Installation
|
|
25
27
|
|
|
@@ -34,7 +36,7 @@ Add it to the Vite configuration:
|
|
|
34
36
|
```ts
|
|
35
37
|
// vite.config.ts
|
|
36
38
|
import { defineConfig } from "vite";
|
|
37
|
-
import react from "@vitejs/plugin-react
|
|
39
|
+
import react from "@vitejs/plugin-react";
|
|
38
40
|
import materialSymbols from "vite-plugin-material-symbols";
|
|
39
41
|
|
|
40
42
|
export default defineConfig({
|
|
@@ -96,9 +98,17 @@ The plugin substitutes the `icon_names` URL parameter **ONLY** in `vite build` m
|
|
|
96
98
|
The plugin accepts an object of the following options:
|
|
97
99
|
|
|
98
100
|
```yaml
|
|
101
|
+
moduleIdRegex:
|
|
102
|
+
type: RegExp
|
|
103
|
+
description: The regex to match module IDs that should be processed for finding icon names
|
|
104
|
+
default: /\.([jt])sx?$/i # *.js, *.jsx, *.ts, *.tsx
|
|
105
|
+
jsxNodeRegex:
|
|
106
|
+
type: RegExp
|
|
107
|
+
description: The regex to match JSX nodes that should be processed in parsed AST (e.g. "jsx", "_jsx" or "jsxs")
|
|
108
|
+
default: /jsx/
|
|
99
109
|
component:
|
|
100
|
-
type: string
|
|
101
|
-
description: The name of JSX component to
|
|
110
|
+
type: string | RegExp
|
|
111
|
+
description: The name of JSX component to get the icon names from (or regex to match the component name)
|
|
102
112
|
default: Icon
|
|
103
113
|
getUrl:
|
|
104
114
|
type: function
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,16 @@ import { Plugin } from "vite";
|
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
type PluginOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The regex to match module IDs that should be processed for finding icon names
|
|
7
|
+
* @default /\.([jt])sx?$/i
|
|
8
|
+
* */
|
|
9
|
+
moduleIdRegex: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* The regex to match JSX nodes that should be processed in parsed AST (e.g. "jsx", "_jsx" or "jsxs")
|
|
12
|
+
* @default /jsx/
|
|
13
|
+
* */
|
|
14
|
+
jsxNodeRegex: RegExp;
|
|
5
15
|
/**
|
|
6
16
|
* Material Symbols CSS Provider. Default: outlined, no infill, 24px, weight 400
|
|
7
17
|
* @see https://fonts.google.com/icons?icon.set=Material+Symbols
|
|
@@ -9,10 +19,10 @@ type PluginOptions = {
|
|
|
9
19
|
* */
|
|
10
20
|
getUrl: (iconNamesParam: string) => string;
|
|
11
21
|
/**
|
|
12
|
-
* The name of JSX component to
|
|
22
|
+
* The name of JSX component to get the icon names from (or regex to match the component name)
|
|
13
23
|
* @default Icon
|
|
14
24
|
* */
|
|
15
|
-
component: string;
|
|
25
|
+
component: string | RegExp;
|
|
16
26
|
/**
|
|
17
27
|
* Enables higher priority for loading symbols
|
|
18
28
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload
|
|
@@ -22,6 +32,8 @@ type PluginOptions = {
|
|
|
22
32
|
preload: boolean;
|
|
23
33
|
};
|
|
24
34
|
declare const plugin: ({
|
|
35
|
+
moduleIdRegex,
|
|
36
|
+
jsxNodeRegex,
|
|
25
37
|
component,
|
|
26
38
|
getUrl,
|
|
27
39
|
preload
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"esquery";const t=e=>e.type===`Literal`&&`value`in e&&typeof e.value==`string`,n=e=>`https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${e}`,r=e=>[`CallExpression[callee.name
|
|
1
|
+
import e from"esquery";const t=e=>e.type===`Literal`&&`value`in e&&typeof e.value==`string`,n=e=>`https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&${e}`,r=(e,t)=>[`CallExpression[callee.name=${`/${e.source}/${e.flags}`}][arguments.0.name=${typeof t==`string`?`'${t}'`:`/${t.source}/${t.flags}`}]`,`.arguments`,`Property[key.name='children'] Literal`].join(` > `),i=e=>{if(!e.size)return``;let t=[];for(let n of e.values())t.push(n);return`icon_names=${t.toSorted().join(`,`)}`},a=({moduleIdRegex:a=/.([jt])sx?$/i,jsxNodeRegex:o=/jsx/,component:s=`Icon`,getUrl:c=n,preload:l=!1}={})=>{let u=new Set;return{name:`material-symbols`,enforce:`pre`,moduleParsed:function({id:n,code:i}){if(!i||!a.test(n))return;let c=this.parse(i),l=r(o,s),d=e.query(c,l).filter(t);for(let{value:e}of d)this.debug({id:n,message:e}),u.add(e)},transformIndexHtml:e=>{let t=c(i(u)),n=[{injectTo:`head`,tag:`link`,attrs:{rel:`stylesheet`,href:t}}];return l&&n.push({injectTo:`head-prepend`,tag:`link`,attrs:{rel:`preload`,as:`style`,href:t}},{injectTo:`head-prepend`,tag:`link`,attrs:{rel:`preconnect`,href:`https://fonts.gstatic.com`}}),{html:e,tags:n}}}};export{a as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-material-symbols",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Selective loading of Material Symbols for production",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"lint": "bun run biome check",
|
|
15
15
|
"prebuild": "tsc --noEmit",
|
|
16
|
-
"build": "tsdown",
|
|
17
|
-
"postbuild": "attw --pack --profile esm-only",
|
|
16
|
+
"build": "bunx --bun tsdown",
|
|
18
17
|
"mdfix": "bunx --bun prettier *.md --write",
|
|
19
18
|
"version": "bun run tools/version.ts",
|
|
20
19
|
"prepublishOnly": "bun lint && bun test && bun run build"
|
|
@@ -30,28 +29,28 @@
|
|
|
30
29
|
"*.md"
|
|
31
30
|
],
|
|
32
31
|
"engines": {
|
|
33
|
-
"node": "^
|
|
32
|
+
"node": "^22 || ^24"
|
|
34
33
|
},
|
|
35
34
|
"peerDependencies": {
|
|
36
|
-
"vite": "^
|
|
35
|
+
"vite": "^8.0.0"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"esquery": "^1.
|
|
38
|
+
"esquery": "^1.7.0"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
|
-
"@arethetypeswrong/
|
|
43
|
-
"@biomejs/biome": "2.
|
|
41
|
+
"@arethetypeswrong/core": "^0.18.2",
|
|
42
|
+
"@biomejs/biome": "2.4.7",
|
|
44
43
|
"@tsconfig/bun": "^1.0.8",
|
|
45
44
|
"@types/bun": "^1.2.17",
|
|
46
45
|
"@types/esquery": "^1.5.4",
|
|
47
46
|
"@types/react": "^19.1.8",
|
|
48
47
|
"@types/react-dom": "^19.1.6",
|
|
49
48
|
"@types/semver": "^7.7.0",
|
|
50
|
-
"@vitejs/plugin-react
|
|
49
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
51
50
|
"react": "^19.1.0",
|
|
52
51
|
"react-dom": "^19.1.0",
|
|
53
52
|
"semver": "^7.7.2",
|
|
54
|
-
"tsdown": "^0.
|
|
53
|
+
"tsdown": "^0.21.2",
|
|
55
54
|
"typescript": "^5.8.3"
|
|
56
55
|
},
|
|
57
56
|
"keywords": [
|