forked from MultiMote/niimblue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
53 lines (49 loc) · 1.59 KB
/
vite.config.ts
File metadata and controls
53 lines (49 loc) · 1.59 KB
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
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
const getDate = (): string => {
const date = new Date();
const fmt = (n: number) => (n > 9 ? n : `0${n}`);
return `${date.getFullYear()}-${fmt(date.getMonth() + 1)}-${fmt(date.getDate())}`;
};
// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte()],
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
__APP_COMMIT__: JSON.stringify(process.env.COMMIT_HASH),
__BUILD_DATE__: JSON.stringify(getDate()),
},
optimizeDeps: {
include: ["@mmote/niimbluelib"], // Fix browser error when using `npm link @mmote/niimbluelib`
},
resolve: {
preserveSymlinks: true, // Fix build error when using `npm link @mmote/niimbluelib`
},
build: {
rollupOptions: {
output: {
manualChunks: (id: string) => {
if (id.endsWith(".css") || id.endsWith(".scss")) {
return "style";
}
if (id.includes("node_modules")) {
if (id.includes("fabric")) {
return "lib.2.fabric";
} else if (id.includes("@capacitor/filesystem") || id.includes("@capacitor/share")) {
return "lib.2.cap";
} else if (id.includes("zod")) {
return "lib.2.zod";
} else if (id.includes("@mmote/niimbluelib")) {
return "lib.2.niim";
}
return "lib.1.other";
}
return null;
},
chunkFileNames: () => {
return "assets/[name].[hash].js";
},
},
},
},
});