vite-plugin-material-symbols 0.7.0 → 0.8.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 +14 -0
- package/README.md +18 -8
- package/dist/index.d.ts +24 -6
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Version 0
|
|
4
4
|
|
|
5
|
+
### v0.8.0
|
|
6
|
+
|
|
7
|
+
- Replaced `getUrl` option with two new ones:
|
|
8
|
+
- `fontUrl` (string): Material Symbols CSS Provider;
|
|
9
|
+
- `paramName` (string): The name of the query parameter to add to the `fontUrl` (default: "icon_names");
|
|
10
|
+
- The plugin will automatically add the query parameter with the icon names list to the font URL.
|
|
11
|
+
|
|
12
|
+
### v0.7.1
|
|
13
|
+
|
|
14
|
+
- Added the following configuration options for flexibility:
|
|
15
|
+
- `moduleIdRegex` — the regex to match module IDs that should be processed for finding icon names;
|
|
16
|
+
- `jsxNodeRegex` — The regex to match JSX nodes that should be processed in parsed AST;
|
|
17
|
+
- The option `component` now also can be a regex to match multiple component names.
|
|
18
|
+
|
|
5
19
|
### v0.7.0
|
|
6
20
|
|
|
7
21
|
- Supporting Vite 8;
|
package/README.md
CHANGED
|
@@ -98,17 +98,27 @@ The plugin substitutes the `icon_names` URL parameter **ONLY** in `vite build` m
|
|
|
98
98
|
The plugin accepts an object of the following options:
|
|
99
99
|
|
|
100
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/
|
|
101
109
|
component:
|
|
102
|
-
type: string
|
|
103
|
-
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)
|
|
104
112
|
default: Icon
|
|
105
|
-
|
|
106
|
-
type:
|
|
113
|
+
fontUrl:
|
|
114
|
+
type: string
|
|
107
115
|
description: Material Symbols CSS Provider
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
# Standard settings: Outlined, no infill, 24px, weight 400
|
|
117
|
+
default: https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0
|
|
118
|
+
paramName:
|
|
119
|
+
type: string
|
|
120
|
+
description: The name of the query parameter to add to the fontUrl
|
|
121
|
+
default: icon_names
|
|
112
122
|
preload:
|
|
113
123
|
type: boolean
|
|
114
124
|
description: Enables higher priority for loading symbols
|
package/dist/index.d.ts
CHANGED
|
@@ -2,17 +2,32 @@ 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
|
|
8
|
-
* @default
|
|
18
|
+
* @default "https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0"
|
|
19
|
+
* */
|
|
20
|
+
fontUrl: string;
|
|
21
|
+
/**
|
|
22
|
+
* The name of the query parameter to add to the fontUrl
|
|
23
|
+
* @default "icon_names"
|
|
9
24
|
* */
|
|
10
|
-
|
|
25
|
+
paramName: string;
|
|
11
26
|
/**
|
|
12
|
-
* The name of JSX component to
|
|
13
|
-
* @default Icon
|
|
27
|
+
* The name of JSX component to get the icon names from (or regex to match the component name)
|
|
28
|
+
* @default "Icon"
|
|
14
29
|
* */
|
|
15
|
-
component: string;
|
|
30
|
+
component: string | RegExp;
|
|
16
31
|
/**
|
|
17
32
|
* Enables higher priority for loading symbols
|
|
18
33
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload
|
|
@@ -22,8 +37,11 @@ type PluginOptions = {
|
|
|
22
37
|
preload: boolean;
|
|
23
38
|
};
|
|
24
39
|
declare const plugin: ({
|
|
40
|
+
moduleIdRegex,
|
|
41
|
+
jsxNodeRegex,
|
|
25
42
|
component,
|
|
26
|
-
|
|
43
|
+
fontUrl,
|
|
44
|
+
paramName,
|
|
27
45
|
preload
|
|
28
46
|
}?: Partial<PluginOptions>) => Plugin;
|
|
29
47
|
//#endregion
|
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
|
|
1
|
+
import e from"esquery";const t=e=>e.type===`Literal`&&`value`in e&&typeof e.value==`string`,n=(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(` > `),r=(e,t,n)=>{let r=new URL(e);if(n.size){let e=[];for(let t of n.values())e.push(t);r.searchParams.append(t,e.toSorted().join(`,`))}return decodeURIComponent(r.toString())},i=({moduleIdRegex:i=/.([jt])sx?$/i,jsxNodeRegex:a=/jsx/,component:o=`Icon`,fontUrl:s=`https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0`,paramName:c=`icon_names`,preload:l=!1}={})=>{let u=new Set;return{name:`material-symbols`,enforce:`pre`,moduleParsed:function({id:r,code:s}){if(!s||!i.test(r))return;let c=this.parse(s),l=n(a,o),d=e.query(c,l).filter(t);for(let{value:e}of d)this.debug({id:r,message:e}),u.add(e)},transformIndexHtml:e=>{let t=r(s,c,u).toString(),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{i 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.8.0",
|
|
4
4
|
"description": "Selective loading of Material Symbols for production",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"lint": "bun run biome check",
|
|
15
15
|
"prebuild": "tsc --noEmit",
|
|
16
|
-
"build": "tsdown",
|
|
16
|
+
"build": "bunx --bun tsdown",
|
|
17
17
|
"mdfix": "bunx --bun prettier *.md --write",
|
|
18
18
|
"version": "bun run tools/version.ts",
|
|
19
19
|
"prepublishOnly": "bun lint && bun test && bun run build"
|