-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.mts
66 lines (62 loc) · 1.55 KB
/
vite.config.mts
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
/// <reference types="vitest" />
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue2'
import markdownPlugin from 'unplugin-vue-markdown/vite'
import history from 'connect-history-api-fallback'
// FROM vite-plugin-rewrite-all (deprecated): allow paths that end in .extensions
function redirectAll() {
return {
name: 'rewrite-all',
configureServer(server) {
return () => {
const handler = history({
disableDotRule: true,
rewrites: [{ from: /\/$/, to: () => '/index.html' }],
})
server.middlewares.use((req, res, next) => {
handler(req, res, next)
})
}
},
}
}
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
base: '/',
build: { sourcemap: false, target: 'esnext' },
esbuild: { target: 'esnext' },
optimizeDeps: {
include: ['sax-wasm'],
},
plugins: [
// vue
vue({ include: [/\.vue$/, /\.md$/] }),
// markdown:
markdownPlugin({}),
// redirectAll allows pages ending in http://path/blah.yaml to load:
redirectAll(),
],
assetsInclude: ['**/*.so'],
test: {
globals: true,
environment: 'jsdom',
},
resolve: {
alias: {
'@': '/src',
'~': '/node_modules',
path: 'path-browserify',
},
},
define:
mode === 'test'
? {
'process.env': [],
}
: {
'process.platform': null,
'process.env': [],
},
}
})