-
Notifications
You must be signed in to change notification settings - Fork 34
/
vite.config.ts
87 lines (83 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
83
84
85
86
87
import { execSync } from "child_process";
import path from "node:path";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import svgLoader from "vite-svg-loader";
import wasmLoader from "vite-plugin-wasm";
import windiCSS from "vite-plugin-windicss";
import topLevelAwait from "vite-plugin-top-level-await";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import webExtension from "vite-plugin-web-extension";
import { buildManifest } from "./src/extension/manifest.ts";
import { EXT_ENTRY_ROOT } from "./src/constants/extension.ts";
const gitHash = execSync("git rev-parse HEAD").toString().trim();
const network = (process.env.VITE_NETWORK as "mainnet" | "testnet") ?? "mainnet";
const port = 5173;
function r(...paths: string[]): string {
return path.resolve(import.meta.dirname, ...paths);
}
const plugins = [
vue(),
windiCSS(),
svgLoader(),
topLevelAwait(),
wasmLoader(),
nodePolyfills({ include: ["buffer"] }) // required by @ledgerhq/* packages
];
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
resolve: {
alias: { "@": "/src" }
},
define: {
"import.meta.env.GIT_COMMIT_HASH": JSON.stringify(gitHash)
},
plugins: [
...(mode === "development" ? plugins : []),
webExtension({
manifest: () => buildManifest(network, mode),
watchFilePaths: [r("src/manifest.ts")],
additionalInputs: [
`${EXT_ENTRY_ROOT}/content-scripts/injected.ts`,
`${EXT_ENTRY_ROOT}/connector/index.html`
],
disableAutoLaunch: true,
htmlViteConfig: { plugins }
})
],
build: {
rollupOptions: {
output: {
sanitizeFileName(name) {
// chromium: filenames starting with "_" are reserved for use by the system.
if (name.startsWith("_")) return name.replace("_", "");
// avoid invalid filenames such as FeeSelector.vue?vue&type=script&setup=true&lang.js
if (name.includes(".vue?")) return name.slice(0, name.indexOf(".vue?"));
return name;
}
}
},
chunkSizeWarningLimit: 1024,
emptyOutDir: true,
outDir: r("dist")
},
optimizeDeps: {
include: [
"vue",
"vue-router",
"pinia",
"@ledgerhq/hw-transport-webusb",
"ledger-ergo-js",
"@vuelidate/core",
"@vuelidate/validators",
"vue-json-pretty",
"@fleet-sdk/babel-fees-plugin",
"ergo-lib-wasm-browser"
]
},
server: {
port,
strictPort: true,
hmr: { port }
}
}));