-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
48 lines (44 loc) · 1.22 KB
/
Copy pathvite.config.ts
File metadata and controls
48 lines (44 loc) · 1.22 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
import { reactRouter } from "@react-router/dev/vite";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig, type Plugin } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import esbuild from "esbuild";
import path from "path";
function serviceWorkerPlugin(): Plugin {
const swSrc = path.resolve(__dirname, "app/sw.ts");
const swDest = path.resolve(__dirname, "public/sw.js");
async function buildSW() {
await esbuild.build({
entryPoints: [swSrc],
outfile: swDest,
bundle: false,
format: "iife",
target: ["chrome90", "firefox88", "safari15"],
sourcemap: false,
});
}
return {
name: "service-worker",
async buildStart() {
await buildSW();
},
configureServer(server) {
server.watcher.add(swSrc);
server.watcher.on("change", async (file) => {
if (file === swSrc) {
await buildSW();
server.ws.send({ type: "full-reload" });
}
});
},
};
}
export default defineConfig({
plugins: [serviceWorkerPlugin(), tailwindcss(), reactRouter(), tsconfigPaths()],
resolve: {
dedupe: ["react", "react-dom"],
},
optimizeDeps: {
include: ["@radix-ui/react-popover", "recharts"],
},
});