vite-plugin-lucide-preprocess 1.0.3 → 1.0.4
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/plugin.d.ts +5 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +37 -34
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
package/dist/plugin.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export function rawModulesToLists(rawModules: string): [string[], string[]];
|
|
|
13
13
|
* @return {string} The dashed icon component name
|
|
14
14
|
*/
|
|
15
15
|
export function iconCompToDashed(component: string): string;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The Vite plugin that preprocesses imports to optimize Lucide icons
|
|
18
|
+
* @return {import("vite").Plugin}
|
|
19
|
+
*/
|
|
17
20
|
export function plugin(): import("vite").Plugin;
|
|
21
|
+
export const importsMatcher: RegExp;
|
|
18
22
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,8CAJsB,MAAM,GAChB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAY/B;AAED;;;;;GAKG;AACH,4CAHqB,MAAM,GACf,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,8CAJsB,MAAM,GAChB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAY/B;AAED;;;;;GAKG;AACH,4CAHqB,MAAM,GACf,MAAM,CAejB;AAID;;;GAGG;AACH,0BAFY,OAAO,MAAM,EAAE,MAAM,CAwChC;AA5CD,oCAAiG"}
|
package/dist/plugin.js
CHANGED
|
@@ -30,45 +30,48 @@ export function iconCompToDashed(component) {
|
|
|
30
30
|
// fix for NxN icons
|
|
31
31
|
.replace(/(\d)x-(\d)/, (_, a, b) => `${a}x${b}`)
|
|
32
32
|
// exception for ClockNN
|
|
33
|
-
.replace(/clock-(\d)-(\d)/, (_, a, b) => `clock-${a}${b}`)
|
|
33
|
+
.replace(/clock-(\d)-(\d)/, (_, a, b) => `clock-${a}${b}`)
|
|
34
|
+
// remove the "Icon" suffix
|
|
35
|
+
.replace(/-icon$/, ""));
|
|
34
36
|
}
|
|
35
37
|
export const importsMatcher = /^(\s*)import\s+\{([^}]*)}\s+from\s+(["'])lucide-(.*?)["'](.*)$/gm;
|
|
36
38
|
/**
|
|
37
39
|
* The Vite plugin that preprocesses imports to optimize Lucide icons
|
|
38
40
|
* @return {import("vite").Plugin}
|
|
39
41
|
*/
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
export function plugin() {
|
|
43
|
+
return {
|
|
44
|
+
name: "vite-plugin-lucide-preprocess",
|
|
45
|
+
enforce: "pre",
|
|
46
|
+
transform: (code, path) => {
|
|
47
|
+
if (ignoredPaths.some(p => path.includes(p)))
|
|
48
|
+
return;
|
|
49
|
+
return {
|
|
50
|
+
code: code.replace(importsMatcher,
|
|
51
|
+
/**
|
|
52
|
+
* @param _ The whole matched string
|
|
53
|
+
* @param initialSpacing {string} The spacing before the matched import statement
|
|
54
|
+
* @param modulesStr {string} The imported icons as a raw string
|
|
55
|
+
* @param quote {string} The quote used in the import statement (either ' or ")
|
|
56
|
+
* @param framework {string} The framework the icons are imported for
|
|
57
|
+
* @param lineEnding {string} The end of the line of the matched import statement (often a semicolon)
|
|
58
|
+
* @return The optimized import statement(s)
|
|
59
|
+
*/
|
|
60
|
+
(_, initialSpacing, modulesStr, quote, framework, lineEnding) => {
|
|
61
|
+
const [modules, types] = rawModulesToLists(modulesStr);
|
|
62
|
+
const moduleImports = modules
|
|
63
|
+
.map(m => `${initialSpacing}import ${m} from ${quote}lucide-${framework}/icons/${iconCompToDashed(m)}${quote}${lineEnding.trimEnd()}`)
|
|
64
|
+
.join(initialSpacing.includes("\n") ? "" : "\n");
|
|
65
|
+
const typesImport = `${initialSpacing}import type { ${types.join(", ")} } from ${quote}lucide-${framework}${quote}${lineEnding.trimEnd()}`;
|
|
66
|
+
return [
|
|
67
|
+
types.length ? typesImport : undefined,
|
|
68
|
+
modules.length ? moduleImports : undefined
|
|
69
|
+
]
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
.join(initialSpacing.includes("\n") ? "" : "\n");
|
|
72
|
+
})
|
|
73
|
+
};
|
|
46
74
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @param _ The whole matched string
|
|
51
|
-
* @param initialSpacing {string} The spacing before the matched import statement
|
|
52
|
-
* @param modulesStr {string} The imported icons as a raw string
|
|
53
|
-
* @param quote {string} The quote used in the import statement (either ' or ")
|
|
54
|
-
* @param framework {string} The framework the icons are imported for
|
|
55
|
-
* @param lineEnding {string} The end of the line of the matched import statement (often a semicolon)
|
|
56
|
-
* @return The optimized import statement(s)
|
|
57
|
-
*/
|
|
58
|
-
(_, initialSpacing, modulesStr, quote, framework, lineEnding) => {
|
|
59
|
-
const [modules, types] = rawModulesToLists(modulesStr);
|
|
60
|
-
const moduleImports = modules
|
|
61
|
-
.map(m => `${initialSpacing}import ${m} from ${quote}lucide-${framework}/icons/${iconCompToDashed(m)}${quote}${lineEnding.trimEnd()}`)
|
|
62
|
-
.join(initialSpacing.includes("\n") ? "" : "\n");
|
|
63
|
-
const typesImport = `${initialSpacing}import type { ${types.join(", ")} } from ${quote}lucide-${framework}${quote}${lineEnding.trimEnd()}`;
|
|
64
|
-
return [
|
|
65
|
-
types.length ? typesImport : undefined,
|
|
66
|
-
modules.length ? moduleImports : undefined
|
|
67
|
-
]
|
|
68
|
-
.filter(Boolean)
|
|
69
|
-
.join(initialSpacing.includes("\n") ? "" : "\n");
|
|
70
|
-
})
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
});
|
|
75
|
+
};
|
|
76
|
+
}
|
|
74
77
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.js"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAU;IAC3C,MAAM,GAAG,GAAG,UAAU;SACpB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAClB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnB,OAAO;QACN,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACvC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC3D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAS;IACzC,OAAO,CACN,SAAS;SACP,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,+CAA+C;QAC9D,sCAAsC;SACrC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACtF,oBAAoB;SACnB,OAAO,CAAC,Y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Q,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;oBAClD,MAAM,WAAW,GAAG,GAAG,cAAc,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,UAAU,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;oBAC3I,OAAO;wBACN,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;wBACtC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;qBAC1C;yBACC,MAAM,CAAC,OAAO,CAAC;yBACf,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBACnD,CAAC,CACD;aACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-lucide-preprocess",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"author": {
|
|
5
5
|
"url": "https://github.com/WarningImHack3r",
|
|
6
6
|
"name": "WarningImHack3r"
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"vite": "^5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"lucide-svelte": "^0.
|
|
34
|
+
"lucide-svelte": "^0.428.0",
|
|
35
35
|
"prettier": "^3.3.3",
|
|
36
|
-
"publint": "^0.2.
|
|
36
|
+
"publint": "^0.2.10",
|
|
37
37
|
"typescript": "^5.5.4",
|
|
38
|
-
"vite": "^5.4.
|
|
38
|
+
"vite": "^5.4.1",
|
|
39
39
|
"vitest": "^2.0.5"
|
|
40
40
|
},
|
|
41
41
|
"main": "./dist/index.js",
|