-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathvite.config.mts
More file actions
96 lines (92 loc) · 2.03 KB
/
Copy pathvite.config.mts
File metadata and controls
96 lines (92 loc) · 2.03 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { defineConfig } from "vite";
import { glob } from "glob";
import { createHtmlPlugin } from "vite-plugin-html";
import { VitePWA } from "vite-plugin-pwa";
import { cloudflare } from "@cloudflare/vite-plugin";
import { sri } from "vite-plugin-sri3";
import crypto from "crypto";
const devMode = process.env.NODE_ENV !== "production";
const pages = await glob(devMode ? "**/*.html" : "*.html");
function randomFileName() {
return crypto.randomBytes(8).toString("hex");
}
export default defineConfig({
base: "/",
appType: "mpa",
server: {
open: true,
strictPort: true,
watch: {
ignored: ["dist/**"]
},
hmr: false
},
build: {
outDir: "dist",
target: "esnext",
rollupOptions: {
input: Object.fromEntries(
pages.map(file => [
file.replace(/\.html$/, ""),
file
])
),
output: {
entryFileNames: () => `assets/${randomFileName()}.js`,
chunkFileNames: () => `assets/${randomFileName()}.js`
}
}
},
esbuild: {
exclude: []
},
plugins: [
createHtmlPlugin({
minify: true,
pages: pages.map(file => ({
filename: file,
template: file,
injectOptions: {
data: {
isDev: process.env.NODE_ENV === "development",
}
}
}))
}),
VitePWA({
injectRegister: "auto",
manifest: {
name: "r/place",
short_name: "place",
description: "There is an empty canvas. You may place a tile anywhere upon it. Team up, engage in canvas wars and create the greatest artworks on the massive multiplayer canvas.",
theme_color: "#ff4500",
background_color: "#ffffff",
display: "standalone",
start_url: "/",
scope: "/",
icons: [
{
"src": "favicon.ico",
"type": "image/x-icon",
"sizes": "256x256"
},
{
"src": "favicon.png",
"type": "image/png",
"sizes": "256x256"
}
]
}
}),
sri({
ignoreMissingAssets: false,
crossorigin: "anonymous",
excludeExternal: true,
includePatterns: [/^\/assets\//]
}),
devMode ? undefined
: cloudflare({
configPath: "./wrangler.jsonc"
})
]
})