-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
81 lines (79 loc) · 1.99 KB
/
vite.config.ts
File metadata and controls
81 lines (79 loc) · 1.99 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import mkcert from "vite-plugin-mkcert";
import { VitePWA, VitePWAOptions } from "vite-plugin-pwa";
import tsconfigPaths from "vite-tsconfig-paths";
import { excludeMsw, fcmSwEnvPlugin } from "./config/vitePlugins";
export default defineConfig(({ command }) => {
const vitePwaBaseConfig: Partial<VitePWAOptions> = {
filename: "pwa-sw.js",
registerType: "autoUpdate",
manifestFilename: "manifest.json",
manifest: {
name: "FineAnts",
short_name: "FineAnts",
description: "Your portfolio management platform",
icons: [
{
src: "/icons/Icon_192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "/icons/Icon_512x512.png",
sizes: "512x512",
type: "image/png",
},
],
display: "standalone",
scope: "/",
start_url: "/",
theme_color: "#21222a",
},
};
if (command === "serve") {
return {
server: {
https: true,
},
plugins: [
mkcert(),
react(),
tsconfigPaths(),
fcmSwEnvPlugin(),
VitePWA({
...vitePwaBaseConfig,
devOptions: {
enabled: true,
},
}),
],
};
} else {
// command === 'build'
return {
plugins: [
react(),
tsconfigPaths(),
excludeMsw(),
VitePWA(vitePwaBaseConfig),
],
build: {
target: "es2022",
rollupOptions: {
input: {
"main": "./index.html",
"firebase-messaging-sw": "./src/firebase-messaging-sw.js",
},
output: {
entryFileNames: (chunkInfo) => {
return chunkInfo.name === "firebase-messaging-sw"
? "[name].js" // put fcm service worker in root
: "assets/[name]-[hash].js"; // others in `assets/`
},
},
},
},
};
}
});