-
-
Notifications
You must be signed in to change notification settings - Fork 505
/
vite.config.js
62 lines (59 loc) · 1.71 KB
/
vite.config.js
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
import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import replace from '@rollup/plugin-replace';
import path from 'path';
import { precompileMarkdown } from './plugins/precompile-markdown/index.js';
import { netlifyPlugin } from './plugins/netlify.js';
import { spaFallbackMiddlewarePlugin } from './plugins/spa-fallback-middleware.js';
import { htmlRoutingMiddlewarePlugin } from './plugins/html-routing-middleware.js';
import { rssFeedPlugin } from './plugins/rss-feed.js';
// TODO: Should we do this for all routes, rely on discovery a bit less?
import { tutorialRoutes } from './src/lib/route-utils.js';
export default defineConfig({
publicDir: 'src/assets',
optimizeDeps: {
include: ['@babel/polyfill', '@rollup/browser', 'sucrase']
},
build: {
target: ['chrome88', 'edge88', 'es2020', 'firefox78', 'safari14'],
outDir: 'build'
},
plugins: [
replace({
'process.env.BRANCH': JSON.stringify(process.env.BRANCH),
preventAssignment: true
}),
preact({
prerender: {
enabled: true,
renderTarget: '#app',
// The routes that will not be discovered automatically
additionalPrerenderRoutes: [
'/404',
'/guide/v8/getting-started',
'/branding',
...Object.keys(tutorialRoutes)
]
}
}),
viteStaticCopy({
targets: [
{
src: './content/**/*.md',
dest: './',
rename: (_name, _fileExtension, fullPath) => path.basename(fullPath).replace(/\.md$/, '.json'),
transform: precompileMarkdown
}
],
structured: true,
watch: {
reloadPageOnChange: true
}
}),
netlifyPlugin(),
spaFallbackMiddlewarePlugin(),
htmlRoutingMiddlewarePlugin(),
rssFeedPlugin()
]
});