-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvite.config.ts
89 lines (83 loc) · 2.09 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
88
89
import { fileURLToPath, URL } from "url";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import vue from "@vitejs/plugin-vue";
import { execSync } from "child_process";
import svgLoader from "vite-svg-loader";
import webfontDownload from "vite-plugin-webfont-dl";
const branch = execSync("git rev-parse --abbrev-ref HEAD").toString().trimEnd();
let base = "/";
if (process.env.NODE_ENV === "production") {
if (
process.env.DEPLOYMENT === "gh-pages" ||
process.env.DEPLOYMENT === "local"
) {
if (branch == "develop") {
base = "/develop/";
} else {
base = "/";
}
} else {
base = "/dist/";
}
}
process.env.VITE_BRANCH_NAME = branch;
process.env.VITE_APP_VERSION = require("./package.json").version;
// https://vitejs.dev/config/
export default defineConfig({
base: base,
plugins: [
vue(),
svgLoader(),
webfontDownload([
"https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap",
]),
VitePWA({
strategies: "injectManifest",
srcDir: "src",
filename: "sw.ts",
manifest: {
name: "QUICKSILVER Configurator",
short_name: "QUICKSILVER",
description:
"Configurator for the QUICKSILVER flight-controller firmware",
theme_color: "#3c7317",
icons: [
{
src: "pwa.png",
sizes: "512x512",
type: "image/png",
},
],
display: "standalone",
background_color: "#FFFFFF",
},
devOptions: {
enabled: true,
type: "module",
},
workbox: {
sourcemap: process.env.NODE_ENV !== "production",
mode: process.env.NODE_ENV,
},
injectManifest: {
globPatterns: [
"**/*.{css,glb,html,ico,jpg,js,png,svg,txt,webmanifest,woff2}",
],
rollupFormat: "iife",
},
}),
],
server: {
port: 8080,
},
resolve: {
alias: {
"node-fetch": "isomorphic-fetch",
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
define: {
"process.env": {},
},
});