-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
89 lines (86 loc) · 3.65 KB
/
vite.config.js
File metadata and controls
89 lines (86 loc) · 3.65 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
import { defineConfig } from 'vite';
import { ViteEjsPlugin } from 'vite-plugin-ejs';
import { VitePWA } from 'vite-plugin-pwa';
import pkg from './package.json';
import childProcess from 'child_process';
const COMMIT_HASH = childProcess.execSync('git rev-parse HEAD').toString().trim();
const BUILD_DATE = new Date().toISOString();
export default defineConfig(({ mode }) => {
const DEV = mode === 'development' || mode === 'development';
const PROD = mode === 'production';
return {
publicDir: 'static',
define: {
'process.env.DEV': DEV,
'process.env.PROD': PROD,
'process.env.BUILD_DATE': JSON.stringify(BUILD_DATE),
'process.env.COMMIT_HASH': JSON.stringify(COMMIT_HASH),
},
plugins: [
ViteEjsPlugin({
htmlWebpackPlugin: {
options: {
title: 'GMZcodes - Dani Gámez Franco',
description: 'Dani Gámez Franco - Staff Web3 Software Engineer / Architect - Summa Cum Laude Computer Science Engineer - Top 1.5% at StackOverflow - JS, TS, React, Next.js, Node.js, tRPC, Clean Software Architecture',
}
}
}),
VitePWA({
injectRegister: null, // the app registers the sw manually in main.js
strategies: 'generateSW',
filename: 'service-worker.js',
outDir: 'dist',
workbox: {
cleanupOutdatedCaches: true,
globIgnores: ['**/*.{png,jpg,jpeg,gif,svg,woff2}'],
additionalManifestEntries: [
{ url: 'manifest.json', revision: null },
{ url: 'dani-gamez-franco-cv-2026.02.11.pdf', revision: null },
{ url: 'llms.txt', revision: null }
],
runtimeCaching: [
{
urlPattern: /\.(?:png|jpg|jpeg|gif|svg|woff2)$/,
handler: 'CacheFirst',
options: {
cacheName: 'images',
expiration: {
maxEntries: 16,
maxAgeSeconds: 30 * 24 * 60 * 60,
},
},
},
{
urlPattern: /^https:\/\/fonts\.googleapis\.com/,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'google-fonts-stylesheets',
expiration: {
maxEntries: 4,
},
},
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com/,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-webfonts',
cacheableResponse: {
statuses: [0, 200],
},
expiration: {
maxEntries: 30,
maxAgeSeconds: 60 * 60 * 24 * 365,
},
},
},
],
},
}),
],
build: {
sourcemap: true,
minify: true,
}
};
});