-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathvite.config.ts
More file actions
115 lines (112 loc) · 3.13 KB
/
vite.config.ts
File metadata and controls
115 lines (112 loc) · 3.13 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { defineConfig } from "vite";
import dyadComponentTagger from "@dyad-sh/react-vite-component-tagger";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { VitePWA } from "vite-plugin-pwa";
import { execSync } from "child_process";
import { readFileSync } from "fs";
const pkg = JSON.parse(readFileSync(path.resolve(__dirname, "package.json"), "utf-8"));
let gitHash = '';
try {
gitHash = execSync('git rev-parse --short HEAD').toString().trim();
} catch (e) {
console.warn('Could not get git hash', e);
gitHash = 'N/A';
}
export default defineConfig(() => ({
define: {
'__APP_VERSION__': JSON.stringify(pkg.version), // Becomes "1.0.0"
'__GIT_HASH__': JSON.stringify(gitHash), // Becomes "(ae04737)"
},
server: {
host: "::",
port: 8080,
},
build: {
sourcemap: false,
},
plugins: [
dyadComponentTagger(),
react(),
VitePWA({
registerType: "prompt",
devOptions: {
enabled: true,
type: "module",
navigateFallback: "index.html",
suppressWarnings: true,
},
workbox: {
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2}"],
navigateFallback: "/index.html",
navigateFallbackDenylist: [/^\/_/, /\/[^/?]+\.[^/]+$/],
maximumFileSizeToCacheInBytes: 15 * 1024 * 1024,
runtimeCaching: [
{
urlPattern: /\.(?:png|jpg|jpeg|svg|gif)$/,
handler: "CacheFirst",
options: {
cacheName: "images-cache",
expiration: {
maxEntries: 60,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
},
},
},
{
urlPattern: /\.(?:js|css)$/,
handler: "StaleWhileRevalidate",
options: {
cacheName: "static-resources-cache",
expiration: {
maxEntries: 60,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
},
},
},
],
},
includeAssets: [
"ThothBlueprint-icon.svg",
"robots.txt",
"browserconfig.xml",
"offline.html",
],
manifest: {
name: "ThothBlueprint",
short_name: "ThothBlueprint",
description: "Visualize your database schema with our intuitive drag-and-drop editor.",
theme_color: "#ffffff",
background_color: "#ffffff",
display: "standalone",
orientation: "any",
scope: "/",
start_url: "/",
categories: ["productivity", "utilities", "developer", "design"],
icons: [
{
src: "ThothBlueprint-icon.svg",
sizes: "192x192",
type: "image/svg+xml",
},
{
src: "ThothBlueprint-icon.svg",
sizes: "512x512",
type: "image/svg+xml",
},
{
src: "ThothBlueprint-icon.svg",
sizes: "512x512",
type: "image/svg+xml",
purpose: "any maskable",
},
],
},
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
}));