-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
40 lines (37 loc) · 957 Bytes
/
vite.config.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
37
38
39
40
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig, type Plugin } from "vite";
import icons from "unplugin-icons/vite";
import { exec } from "node:child_process";
function buildWebxdc(fileName: string, exclude: string[] = []): Plugin {
return {
name: "webxdc-build",
async closeBundle() {
await new Promise<void>((resolve) =>
exec(
`cd build && zip -9 --recurse-paths "${fileName}" --exclude ${exclude} -- *`,
(error, stdout, stderr) => {
if (error || stderr) console.error(error ?? stderr);
console.log(stdout);
resolve();
},
),
);
},
};
}
export default defineConfig({
plugins: [
sveltekit(),
icons({
compiler: "svelte",
webComponents: {
autoDefine: true,
iconPrefix: "md-icon",
shadow: true,
},
defaultClass: "icon",
}),
buildWebxdc("notes.xdc", ["webxdc.js", "webxdc.d.ts", '"./*.sh"', '"./*.xdc"']),
],
server: { open: "/index.html" },
});