-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.js
79 lines (73 loc) · 2.04 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
73
74
75
76
77
78
79
import { defineConfig } from "vite"
import { visualizer } from "rollup-plugin-visualizer"
import replace from "rollup-plugin-re"
import vue from "@vitejs/plugin-vue"
import path from "path"
import nodePolyfills from "vite-plugin-node-stdlib-browser"
const aliases = {
"@": path.resolve(__dirname, "./src"),
"@ui": path.resolve(__dirname, "./src/components/ui"),
"@base": path.resolve(__dirname, "./src/components/base"),
"@views": path.resolve(__dirname, "./src/views"),
"@local": path.resolve(__dirname, "./src/components/local"),
"@layout": path.resolve(__dirname, "./src/components/layout"),
"@modals": path.resolve(__dirname, "./src/components/local/modals"),
"@modules": path.resolve(__dirname, "./src/components/modules"),
"@sanity": path.resolve(__dirname, "./src/components/sanity"),
"@typography": path.resolve(__dirname, "./src/components/typography"),
"@api": path.resolve(__dirname, "./src/api"),
"@config": path.resolve(__dirname, "./src/services/config"),
"@sdk": path.resolve(__dirname, "./src/services/sdk"),
"@utils": path.resolve(__dirname, "./src/services/utils"),
"@store": path.resolve(__dirname, "./src/store"),
}
export default (ctx) => {
const isBuild = ctx.command === "build"
return defineConfig({
plugins: [
vue(),
nodePolyfills(),
...(process.env.STATS
? [
{
...visualizer({
filename: "./dist/stats.html",
gzipSize: true,
open: true,
}),
enforce: "post",
apply: "build",
},
]
: []),
{
...replace({
include: ["node_modules/@airgap/**"],
replaces: {
...(isBuild && {
"import * as qrcode from 'qrcode-generator';":
"import qrcode from 'qrcode-generator';",
}),
},
}),
enforce: "pre",
},
],
define: {
global: "window",
"process.env": {},
},
resolve: {
preferRelative: false,
alias: {
...aliases,
"@airgap/beacon-dapp": path.resolve(
__dirname,
`./node_modules/@airgap/beacon-dapp/dist/${
isBuild ? "esm" : "cjs"
}/index.js`,
),
},
},
})
}