-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.js
More file actions
52 lines (49 loc) · 1.36 KB
/
vite.config.js
File metadata and controls
52 lines (49 loc) · 1.36 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
import { defineConfig } from 'vite';
const contactLinks = [
{ label: 'mail', href: 'mailto:[email protected]' },
{ label: 'github', href: 'https://github.com/yvhr' },
{ label: 'linkedin', href: 'https://linkedin.com/in/josephharveyangeles' },
{ label: 'x', href: 'https://x.com/yev' },
];
function htmlInjectPlugin(links) {
const buildDate = new Date().toISOString().split('T')[0];
return {
name: 'html-inject',
transformIndexHtml(html) {
const anchors = links
.map(({ label, href }) => {
const isMailto = href.startsWith('mailto:');
const attrs = isMailto
? `href="${href}"`
: `href="${href}" target="_blank" rel="noreferrer"`;
return `<a ${attrs}>${label}</a>`;
})
.join('\n ');
return html
.replace('<!-- CONTACT_LINKS -->', anchors)
.replace('<!-- BUILD_DATE -->', buildDate);
},
};
}
export default defineConfig({
root: 'src',
publicDir: '../public',
build: {
outDir: '../dist',
emptyOutDir: true,
rollupOptions: {
input: {
main: 'src/index.html',
vertex: 'src/vertex.html',
},
},
minify: 'esbuild',
cssMinify: true,
reportCompressedSize: true,
chunkSizeWarningLimit: 500,
},
plugins: [htmlInjectPlugin(contactLinks)],
server: {
open: true,
},
});