Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
77 lines (73 loc) · 2.09 KB
/
Copy pathvite.config.js
File metadata and controls
77 lines (73 loc) · 2.09 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
import { defineConfig } from 'vite'
import { fillSlots } from './src/content/render.js'
import { site } from './src/content/data.js'
const SITE = site.url
/**
* Renders the content from src/content/data.js into index.html, in dev and in
* the build, so the page ships real text rather than an empty shell.
*/
function content () {
return {
name: 'swissa-content',
transformIndexHtml: {
order: 'pre',
handler (html) {
return fillSlots(html)
}
},
/**
* robots.txt and sitemap.xml are emitted rather than committed, so the
* sitemap's lastmod is the date of the build that produced it and cannot
* drift away from the content it describes.
*/
generateBundle () {
const today = new Date().toISOString().slice(0, 10)
this.emitFile({
type: 'asset',
fileName: 'robots.txt',
source: [
'User-agent: *',
'Allow: /',
'',
`Sitemap: ${SITE}sitemap.xml`,
''
].join('\n')
})
this.emitFile({
type: 'asset',
fileName: 'sitemap.xml',
source: [
'<?xml version="1.0" encoding="UTF-8"?>',
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
' <url>',
` <loc>${SITE}</loc>`,
` <lastmod>${today}</lastmod>`,
' <changefreq>monthly</changefreq>',
' </url>',
'</urlset>',
''
].join('\n')
})
},
handleHotUpdate ({ file, server }) {
if (file.includes('/src/content/')) {
server.ws.send({ type: 'full-reload' })
return []
}
}
}
}
export default defineConfig({
base: '/',
plugins: [content()],
build: {
target: 'es2022',
assetsInlineLimit: 2048,
sourcemap: false,
// three's WebGLRenderer and shader library are the whole of the scene chunk
// and neither is tree-shakeable; the chunk is already split off the entry
// and loaded after first paint, so the default 500 kB warning is only noise.
chunkSizeWarningLimit: 600
},
server: { port: 5173, host: true }
})