-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
107 lines (98 loc) · 2.62 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
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
import type { UserConfigExport } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from 'path'
import vike from 'vike/plugin'
import vuetify from 'vite-plugin-vuetify'
import { vavite } from 'vavite'
import { compression } from 'vite-plugin-compression2'
import vueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import { nodeLoaderPlugin } from '@vavite/node-loader/plugin'
import { OPTIONS } from './src/i18n'
import { sitemap } from './sitemap'
import { DB } from './server/storage'
export default defineConfig(async ({ mode }) => {
const db = await new DB().init()
Object.assign(process.env, loadEnv(mode, process.cwd()))
let links = []
if (mode === 'production') {
const locations = await db.getLocations()
if (locations) {
locations.forEach((item) => {
links.push(
{
url: `/donation-location/${item.donationLocation.name}`,
links: OPTIONS.availableLocales.map(locale => ({
url: `/${locale}/donation-location/${item.donationLocation.name}`,
lang: locale
}))
})
})
}
}
const buildSteps = [
// https://vike.dev/disableAutoFullBuild
// this in conjunction with vike.serveClientAssetsInDev: true
// allows to specify server/client config separately
{ name: 'client' },
{
name: 'server',
config: {
build: {
emptyOutDir: true,
ssr: true
}
}
}
]
const ssr = {
noExternal: [
'@fawmi/vue-google-maps',
'vuetify',
'@googlemaps/markerclusterer',
'date-fns'
]
}
const optimizeDeps = {
include: ['@fawmi/vue-google-maps', 'fast-deep-equal']
}
return {
buildSteps,
ssr,
optimizeDeps,
plugins: [
nodeLoaderPlugin(),
vue(),
vuetify(),
vike({ disableAutoFullBuild: true }),
vavite({
serverEntry: '/server/index.ts',
serveClientAssetsInDev: true
}),
sitemap(
{
outDir: 'dist/client',
hostname: process.env.VITE_HOST_URL || 'http://localhost/',
links
// readable: true,
// generateRobotsTxt: true,
// robots: [{
// userAgent: '*',
// disallow: '/all'
// }],
// dynamicRoutes,
// exclude: ['/all']
}),
vueI18nPlugin({
ssr: true,
include: [path.resolve(__dirname, './src/i18n/*.json')]
}),
compression()
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
}
} satisfies UserConfigExport
})