-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.ts
76 lines (72 loc) · 1.8 KB
/
vite.config.ts
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
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import analog from '@analogjs/platform';
// Only run in Netlify CI
let base = process.env['URL'] || 'http://localhost:5173';
if (process.env['NETLIFY'] === 'true') {
if (process.env['CONTEXT'] === 'deploy-preview') {
base = `${process.env['DEPLOY_PRIME_URL']}/`;
}
}
process.env['VITE_ANALOG_BASE_URL'] = base;
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
build: {
target: ['es2020'],
outDir: 'dist/client'
},
optimizeDeps: {
include: ['@angular/common', 'reading-time']
},
plugins: [
analog({
static: true,
prerender: {
routes: async() => [
'/',
'/about',
'/blog',
'/talks',
{
contentDir: '/src/content',
transform(file) {
return `/blog/posts/${file.attributes['slug']}`;
},
},
{
contentDir: '/src/content',
transform(file) {
return `/api/v1/og-images/${file.attributes['slug']}.png?title=${file.attributes['title']}`;
},
}
],
sitemap: {
host: base
}
},
nitro: {
logLevel: 3,
prerender: {
concurrency: 1
},
hooks: {
'prerender:generate': (route) => {
route.route = route.route.split('?')[0];
route.fileName = route.fileName?.split('?')[0];
}
}
}
}),
],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['src/test.ts'],
include: ['**/*.spec.ts'],
},
define: {
'import.meta.vitest': mode !== 'production',
// fix for readingtime
'process.env.NODE_DEBUG': mode !== 'production' ? '"true"' : false
},
}));