This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
vite.config.ts
104 lines (101 loc) · 3.88 KB
/
vite.config.ts
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
97
98
99
100
101
102
103
104
import react from "@vitejs/plugin-react";
import jotaiDebugLabel from "jotai/babel/plugin-debug-label";
import jotaiReactRefresh from "jotai/babel/plugin-react-refresh";
import { fileURLToPath } from "url";
import { defineConfig } from "vite";
import ViteFaviconsPlugin from "vite-plugin-favicon";
import { VitePWA } from "vite-plugin-pwa";
const maximumFileSizeToCacheInBytes = 5 * 1024 * 1024; // 5 MB
export default defineConfig(({ command, mode }) => {
const isDevMode = mode === "development";
return {
base: "/",
build: {
assetsDir: "assets",
minify: !isDevMode,
outDir: "dist",
sourcemap: isDevMode,
},
define: {
DB_BUILD_TIME: Date.now(),
DB_DEVMODE: isDevMode,
},
plugins: [
react({ babel: { plugins: [jotaiDebugLabel, jotaiReactRefresh] } }),
VitePWA({
includeAssets: [
"assets/*.png",
// these are technically not necessary, but it's annoying that you can't access these with your
// browser anymore without this. Maybe we should switch to a network first SW.
"*.json",
"map/*.json",
"sitemap.xml",
"robots.txt",
],
manifest: {
categories: [
"games",
"utilities"
],
screenshots: [
{
label: "Screenshot of an build in Dauntless Builder",
platform: "wide",
sizes: "1920x1080",
src: "https://raw.githubusercontent.com/atomicptr/dauntless-builder/master/docs/assets/app-screenshot.png",
type: "image/png"
}
],
shortcuts: [
{
description: "Create a new build!",
icons: [],
name: "New Build",
url: "/b/new",
},
{
description: "Know what perks you want? Find a fitting build right here!",
icons: [],
name: "Build Finder",
url: "/b/finder",
},
{
description: "The best builds made by the community!",
icons: [],
name: "Meta Builds",
url: "/b/meta",
}
]
},
registerType: "autoUpdate",
workbox: {
cleanupOutdatedCaches: true,
clientsClaim: true,
maximumFileSizeToCacheInBytes,
sourcemap: isDevMode,
}
}),
command === "build"
? ViteFaviconsPlugin({
favicons: {
appDescription: "Create and share Dauntless builds with your friends!",
appName: "Dauntless Builder",
appleStatusBarStyle: "black-translucent",
background: "#121212",
theme_color: "#272727",
},
logo: "public/assets/icon.png",
})
: undefined,
],
resolve: {
alias: {
"@json": fileURLToPath(new URL("./src/json", import.meta.url)),
"@src": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
port: 3000,
},
};
});