-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathvite.config.ts
More file actions
96 lines (94 loc) · 2.89 KB
/
Copy pathvite.config.ts
File metadata and controls
96 lines (94 loc) · 2.89 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 vue from "@vitejs/plugin-vue";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import { VitePWA } from "vite-plugin-pwa";
import tailwindcss from "@tailwindcss/vite";
import path from "path";
import { execSync } from "child_process";
// In Docker builds, VITE_GIT_COMMIT/VITE_BUILD_DATE are supplied as build
// args (see docker/Dockerfile) since .dockerignore excludes .git, so `git`
// isn't available inside the build context. Outside Docker (local dev/build),
// fall back to reading the commit straight from the working tree.
//
// These are set on process.env (rather than passed via `define`) so they
// flow through Vite's built-in import.meta.env.VITE_* mechanism, which
// (unlike a custom `define` entry) is reliably substituted in both the dev
// server and the production build.
const isDockerBuild = !!process.env.VITE_GIT_COMMIT;
if (!process.env.VITE_GIT_COMMIT) {
try {
process.env.VITE_GIT_COMMIT = execSync("git rev-parse --short HEAD")
.toString()
.trim();
} catch {
process.env.VITE_GIT_COMMIT = "unknown";
}
}
if (!process.env.VITE_BUILD_DATE) {
process.env.VITE_BUILD_DATE = new Date().toISOString();
}
process.env.VITE_BUILD_SOURCE = isDockerBuild ? "docker" : "local";
export default defineConfig({
plugins: [
vue(),
tailwindcss(),
nodePolyfills({
include: [
"buffer",
"crypto",
"stream",
"path",
"util",
"process",
"vm",
"url",
"fs",
],
globals: {
Buffer: true,
global: true,
process: true,
},
}),
VitePWA({
registerType: "autoUpdate",
filename: "service-worker.js",
manifest: false, // Use existing manifest.json in public
workbox: {
globPatterns: ["**/*.{js,css,html,ico,png,svg,json,vue,txt,woff2}"],
globIgnores: ["**/*.xcf", "**/node_modules/**/*"],
cleanupOutdatedCaches: true,
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10MB
},
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"vue-i18n": "vue-i18n/dist/vue-i18n.esm-bundler.js",
// libsodium-wrappers-sumo's published ESM build has a broken relative
// import ("./libsodium-sumo.mjs") that doesn't resolve across packages.
// Force the CJS build instead, which requires the bare "libsodium-sumo"
// specifier and resolves correctly.
"libsodium-wrappers-sumo": path.resolve(
__dirname,
"node_modules/libsodium-wrappers-sumo/dist/modules-sumo/libsodium-wrappers.js"
),
},
},
envPrefix: ["VITE_", "VUE_APP_"],
define: {
__INTLIFY_PROD_DEVTOOLS__: false,
__VUE_I18N_FULL_INSTALL__: true,
__VUE_I18N_LEGACY_API__: true,
},
server: {
port: 8080,
},
build: {
outDir: "dist",
commonjsOptions: {
transformMixedEsModules: true,
},
},
});