forked from jameswilce/DevMinDArT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
68 lines (64 loc) · 1.62 KB
/
vite.config.js
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
import { defineConfig } from "vite";
import { serwist } from "@serwist/vite";
export default defineConfig({
build: {
target: "esnext",
outDir: "dist",
assetsDir: "assets",
emptyOutDir: true,
chunkSizeWarningLimit: 1100,
rollupOptions: {
input: {
main: "/index.html",
},
output: {
manualChunks: (id) => {
if (id.includes("p5")) {
return "p5";
}
if (id.includes("/apps/")) {
return "drawing-apps";
}
if (id.includes("/components/")) {
return "components";
}
if (id.includes("/utils/")) {
return "utils";
}
},
chunkFileNames: "js/[name]-[hash].js",
entryFileNames: "js/[name]-[hash].js",
assetFileNames: ({ name }) => {
if (/\.(mp3|wav)$/.test(name ?? "")) {
return "sound/[name][extname]";
}
if (/\.(png|jpe?g|svg|webp)$/.test(name ?? "")) {
return "assets/[name]-[hash][extname]";
}
if (/\.css$/.test(name ?? "")) {
return "css/[name]-[hash][extname]";
}
if (/\.(woff2?)$/.test(name ?? "")) {
return "assets/[name]-[hash][extname]";
}
return "assets/[name]-[hash][extname]";
},
},
},
},
server: {
port: 3000,
open: true,
},
plugins: [
serwist({
swSrc: "./sw.js",
swDest: "dist/sw.js",
globDirectory: "dist",
globPatterns: ["**/*.{html,js,css}", "assets/**/*", "sound/**/*"],
}),
],
optimizeDeps: {
include: ["p5"],
},
});