-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvite.config.js
72 lines (68 loc) · 1.92 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
69
70
71
72
import { sveltekit } from "@sveltejs/kit/vite"
import { defineConfig } from "vite"
import { nodePolyfills } from "vite-plugin-node-polyfills"
import removeAttribute from "@castlenine/vite-remove-attribute"
import path from "path"
import { execSync } from "child_process"
// Function to get the latest Git commit hash
function getCommitHash() {
try {
return execSync("git rev-parse HEAD").toString().trim()
} catch (error) {
console.error("Error fetching commit hash:", error)
return "unknown"
}
}
const IS_PRODUCTION = process.env.NODE_ENV === "production"
export default defineConfig({
server: {
host: "0.0.0.0",
port: 5173,
},
resolve: {
alias: {
$serviceworker: path.resolve(__dirname, "src/serviceworker"),
$lib: path.resolve(__dirname, "src/lib"),
"@": path.resolve(__dirname, "src"),
},
},
plugins: [
IS_PRODUCTION
? removeAttribute({
extensions: ["svelte"],
attributes: ["data-cy", "hook"],
})
: null,
sveltekit(),
nodePolyfills(),
],
optimizeDeps: {
include: ["voice-activity-detection"],
exclude: ["warp-wasm"],
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@use "@/variables.scss" as *;',
api: "modern-compiler",
importers: [
// ...
],
},
},
},
define: {
__COMMIT_HASH__: JSON.stringify(getCommitHash()),
},
envPrefix: ["VITE_", "TAURI_"],
build: {
target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13",
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
sourcemap: !!process.env.TAURI_DEBUG,
},
esbuild: {
supported: {
bigint: true,
},
},
})