forked from bastienwirtz/homer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
94 lines (89 loc) · 2.28 KB
/
vite.config.js
File metadata and controls
94 lines (89 loc) · 2.28 KB
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
93
94
import { VitePWA } from "vite-plugin-pwa";
import { fileURLToPath, URL } from "url";
import fs from "fs";
import path from "path";
import process from "process";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { version } from "./package.json";
function writeVersionPlugin() {
return {
name: "write-version",
closeBundle() {
fs.writeFileSync("dist/VERSION", version);
},
};
}
// https://vitejs.dev/config/
export default defineConfig({
base: "",
build: {
assetsDir: "resources",
},
define: {
__APP_VERSION__: JSON.stringify(version),
},
plugins: [
writeVersionPlugin(),
// Custom plugin to serve dummy-data JSON files without sourcemap injection
{
name: "dummy-data-json-handler",
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (req.url?.startsWith("/dummy-data/")) {
// Remove query parameters from URL to get the actual file path
const urlWithoutQuery = req.url.split("?")[0];
const filePath = path.join(process.cwd(), urlWithoutQuery);
if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {
res.end(fs.readFileSync(filePath, "utf8"));
return;
}
}
next();
});
},
},
vue(),
VitePWA({
registerType: "autoUpdate",
useCredentials: true,
manifestFilename: "assets/manifest.json",
manifest: {
name: "Homer dashboard",
short_name: "Homer",
description: "Home Server Dashboard",
theme_color: "#3367D6",
start_url: "../",
scope: "../",
icons: [
{
src: "./icons/pwa-192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "./icons/pwa-512x512.png",
sizes: "512x512",
type: "image/png",
},
],
},
workbox: {
navigateFallback: null,
},
}),
],
resolve: {
alias: {
"~": fileURLToPath(new URL("./node_modules", import.meta.url)),
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler",
},
},
},
});