-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanel-icons.vite.ts
36 lines (31 loc) · 1010 Bytes
/
panel-icons.vite.ts
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
import fs from 'node:fs';
import path from 'node:path';
import Icons from 'unplugin-icons/vite';
import IconsResolver from 'unplugin-icons/resolver';
import Components from 'unplugin-vue-components/vite';
function generatePanelIcons() {
const dir = path.join(path.dirname(require.resolve('@scayle/panel-icons')), 'icons');
const icons: { [key: string]: string } = {};
fs.readdirSync(dir).forEach(function(file) {
const simpleName: string = file.replace('.svg', '');
icons[simpleName] = fs.readFileSync(path.join(dir, file)).toString('utf8');
});
return icons;
}
export const ComponentsPlugin = () =>
Components({
resolvers: [
IconsResolver({
prefix: 'icon',
customCollections: ['panel'],
}),
],
});
export const IconsPlugin = () =>
Icons({
compiler: 'vue3',
defaultClass: 'icon',
customCollections: {
panel: generatePanelIcons(),
},
});