-
Notifications
You must be signed in to change notification settings - Fork 420
/
Copy pathvite.js
57 lines (51 loc) · 1.44 KB
/
vite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { fileURLToPath } from "node:url";
import AutoImport from "unplugin-auto-import/vite";
import IconsResolver from "unplugin-icons/resolver";
import Icons from "unplugin-icons/vite";
import { FileSystemIconLoader } from "unplugin-icons/loaders";
import Unfonts from "unplugin-fonts/vite";
const ABSOLUTE_PATH = /^\/|^[a-zA-Z]:\//;
export default [
VinxiAutoImport({
resolvers: [
IconsResolver({
prefix: "Icon",
extension: "jsx",
customCollections: ["cap"],
}),
],
dts: fileURLToPath(new URL("./src/auto-imports.d.ts", import.meta.url)),
}),
Icons({
compiler: "solid",
enabledCollections: ["lucide"],
customCollections: {
cap: FileSystemIconLoader(
fileURLToPath(new URL("./icons", import.meta.url))
// (svg) => svg.replace(/^<svg /, '<svg stroke="currentColor" ')
),
},
}),
Unfonts({
fontsource: {
families: [{ name: "Geist Sans", weights: [400, 500, 700] }],
},
}),
];
// Workaround for https://github.com/solidjs/solid-start/issues/1374
/**
* @param {import("unplugin-auto-import/dist/types.d.ts").Options} options
*/
function VinxiAutoImport(options) {
const autoimport = AutoImport(options);
return {
...autoimport,
transform(src, id) {
let pathname = id;
if (ABSOLUTE_PATH.test(id)) {
pathname = new URL(`file://${id}`).pathname;
}
return autoimport.transform(src, pathname);
},
};
}