forked from MutinyWallet/mutiny-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
82 lines (78 loc) · 2.47 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
import child from "node:child_process";
import path from "node:path";
import { defineConfig } from "vite";
import { comlink } from "vite-plugin-comlink";
import { VitePWA, VitePWAOptions } from "vite-plugin-pwa";
import solid from "vite-plugin-solid";
import wasm from "vite-plugin-wasm";
import manifest from "./manifest";
const commitHash =
process.env.VITE_COMMIT_HASH ??
child.execSync("git rev-parse --short HEAD").toString().trim();
const pwaOptions: Partial<VitePWAOptions> = {
base: "/",
registerType: "prompt",
devOptions: {
enabled: false
},
workbox: {
navigateFallback: "/index.html",
globPatterns: ["**/*.{js,css,html,svg,png,gif,wasm}"],
// mutiny_wasm is 10mb, so we'll do 25mb to be safe
maximumFileSizeToCacheInBytes: 25 * 1024 * 1024
},
includeAssets: ["favicon.ico", "robots.txt"],
manifest: manifest
};
export default defineConfig({
build: {
target: "esnext",
outDir: "dist/public",
emptyOutDir: true
},
server: {
port: 3420,
fs: {
// Allow serving files from one level up (so that if mutiny-node is a sibling folder we can use it locally)
allow: [".."]
}
},
plugins: [comlink(), wasm(), solid(), VitePWA(pwaOptions)],
worker: {
plugins: () => [comlink(), wasm()],
format: "es"
},
define: {
"import.meta.env.__COMMIT_HASH__": JSON.stringify(commitHash),
"import.meta.env.__RELEASE_VERSION__": JSON.stringify(
process.env.npm_package_version
)
},
resolve: {
alias: [{ find: "~", replacement: path.resolve(__dirname, "./src") }]
},
optimizeDeps: {
// Don't want vite to bundle these late during dev causing reload
include: [
"qr-scanner",
"@solid-primitives/upload",
"i18next",
"i18next-browser-languagedetector",
"@capacitor-mlkit/barcode-scanning",
"@capacitor/app",
"@capacitor/app-launcher",
"@capacitor/clipboard",
"@capacitor/core",
"@capacitor/filesystem",
"@capacitor/haptics",
"@capacitor/share",
"@capacitor/status-bar",
"@capacitor/toast"
],
// This is necessary because otherwise `vite dev` can't find the wasm
exclude: ["@mutinywallet/mutiny-wasm"],
esbuildOptions: {
target: "esnext"
}
}
});