-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
97 lines (96 loc) · 3.14 KB
/
vite.config.ts
File metadata and controls
97 lines (96 loc) · 3.14 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { VitePWA } from 'vite-plugin-pwa';
import { createHtmlPlugin } from 'vite-plugin-html';
import { getFediverseProfileUrl, isDarkishTheme } from './src/utils';
import CONFIG from './gitprofile.config';
// https://vitejs.dev/config/
export default defineConfig({
base: CONFIG.base || '/',
plugins: [
react(),
createHtmlPlugin({
minify: true,
inject: {
data: {
metaTitle: CONFIG.seo.title,
metaDescription: CONFIG.social.coreid ? CONFIG.seo.description + ' / Core ID: ' + CONFIG.social.coreid : CONFIG.seo.description,
metaImageURL: CONFIG.seo.githubId ? 'https://avatars.githubusercontent.com/u/' + CONFIG.seo.githubId : CONFIG.seo.imageURL,
metaPaytoProperty: CONFIG.seo.payto?.property || '',
metaPaytoContent: CONFIG.seo.payto?.content || '',
metaThemeColor: isDarkishTheme(CONFIG.themeConfig.defaultTheme) ? '#000000' : '#ffffff',
fediverseRelMe: (() => {
const href = getFediverseProfileUrl(CONFIG.social?.fediverse);
return href
? `<link rel="me" href="${href.replace(/"/g, '"')}" />`
: '';
})(),
googleAnalytics: CONFIG.googleAnalytics.id ? `
<script async src="https://www.googletagmanager.com/gtag/js?id=${CONFIG.googleAnalytics.id}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', '${CONFIG.googleAnalytics.id}');
</script>
` : '',
},
},
}),
VitePWA({
registerType: 'autoUpdate',
manifest: {
name: CONFIG.seo.title || 'Portfolio',
short_name: 'Portfolio',
description: CONFIG.seo.description || '',
icons: [
{
src: CONFIG.seo.githubId ? 'https://avatars.githubusercontent.com/u/' + CONFIG.seo.githubId + '?s=16' : CONFIG.seo.imageURL,
sizes: '16x16',
type: 'image/png',
},
{
src: CONFIG.seo.githubId ? 'https://avatars.githubusercontent.com/u/' + CONFIG.seo.githubId + '?s=32' : CONFIG.seo.imageURL,
sizes: '32x32',
type: 'image/png',
},
{
src: CONFIG.seo.githubId ? 'https://avatars.githubusercontent.com/u/' + CONFIG.seo.githubId + '?s=192' : CONFIG.seo.imageURL,
sizes: '192x192',
type: 'image/png',
},
],
},
}),
],
css: {
modules: {
localsConvention: 'camelCase',
},
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
define: {
CONFIG: CONFIG,
},
build: {
cssMinify: 'lightningcss',
cssCodeSplit: true,
rollupOptions: {
output: {
manualChunks(id) {
if (
id.includes('node_modules/react-dom/') ||
id.includes('node_modules/react/')
) {
return 'vendor';
}
},
},
},
chunkSizeWarningLimit: 1000,
},
});