-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathvite.config.js
92 lines (85 loc) · 3.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
80
81
82
83
84
85
86
87
88
89
90
91
92
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-env node */
import path from "path";
import html from "vite-plugin-html";
import vue from "@vitejs/plugin-vue";
import vueI18n from "@intlify/vite-plugin-vue-i18n";
import { VitePWA } from "vite-plugin-pwa";
import { getLastCommit } from "git-last-commit";
import { defineConfig } from "vite";
import packageJson from "./package.json";
export default async function ({ mode }) {
const isProduction = mode === "production";
const isElectron = process.env.IS_ELECTRON === "true";
// Output directories
const webOutDir = "dist/web";
const electronOutDir = "dist/electron";
const lastCommit = await new Promise((resolve, reject) =>
getLastCommit((err, commit) => {
if (err != null) reject(err);
else resolve(commit);
})
);
let contentSecurityPolicy = [
"default-src 'self'",
"connect-src 'self' " +
[
"grpc-web.testnet.myhbarwallet.com",
"grpc-web.previewnet.myhbarwallet.com",
"grpc-web.myhbarwallet.com",
"api.coingecko.com",
"v2.api.kabuto.sh",
"v2.api.testnet.kabuto.sh",
"mainnet-public.mirrornode.hedera.com",
"testnet.mirrornode.hedera.com",
"previewnet.mirrornode.hedera.com",
"node01-00-grpc.swirlds.com",
"testnet-node00-00-grpc.hedera.com",
"testnet-node01-00-grpc.hedera.com",
"testnet-node02-00-grpc.hedera.com",
"testnet-node03-00-grpc.hedera.com",
"testnet-node04-00-grpc.hedera.com",
"testnet-node05-00-grpc.hedera.com",
"testnet-node06-00-grpc.hedera.com",
].join(" "),
"font-src 'self' data:",
isProduction ? "style-src 'self'" : "style-src 'self' 'unsafe-inline'",
];
return defineConfig({
base: isElectron ? "./" : "/",
plugins: [
html({
inject: {
injectData: {
contentSecurityPolicy: contentSecurityPolicy.join("; "),
},
},
}),
vue(),
vueI18n({
include: path.resolve(__dirname, "./locales/**"),
}),
VitePWA()
],
resolve: {
alias: {
awilix: "awilix/lib/awilix.browser.js",
"vue-i18n": "vue-i18n/dist/vue-i18n.runtime.esm-bundler.js",
},
},
optimizeDeps: {
exclude: ["path", "electron-window-state"],
include: ["long/src/long.js"],
},
define: {
__TEST__: !isProduction,
__APP_VERSION__: JSON.stringify(packageJson.version),
__APP_LAST_COMMIT_SHORT_HASH__: JSON.stringify(
lastCommit.shortHash
),
},
build: {
outDir: isElectron ? electronOutDir : webOutDir,
},
});
}