-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
74 lines (72 loc) · 1.87 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
import { join } from 'path'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import VueJsx from '@vitejs/plugin-vue-jsx'
import Pages from 'vite-plugin-pages'
import Markdown from 'vite-plugin-md'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Vue(),
VueJsx(),
Pages({
pagesDir: [
{ dir: join(__dirname, './src/render/pages'), baseRoute: '' },
// { dir: './src/render/pages/users', baseRoute: 'user' },
],
exclude: ['**/components/*.vue', '**/store/'],
extensions: ['vue', 'md'],
syncIndex: true,
replaceSquareBrackets: true,
extendRoute(route) {
console.log('+++++', route)
if (route.path === '/') {
// Index is unauthenticated.
return route
}
if (route.name === 'about') {
route.props = (route) => ({ query: route.query.q })
}
if (route.name === 'components') {
return {
...route,
beforeEnter: (route) => {
// eslint-disable-next-line no-console
console.log(route)
},
}
}
// Augment the route with meta that indicates that the route requires authentication.
return {
...route,
meta: { auth: true },
}
},
}),
Markdown(),
],
root: join(__dirname, 'src/render'),
base: './',
build: {
outDir: join(__dirname, 'dist/render'),
emptyOutDir: true,
rollupOptions: {
input: {
main: join(__dirname, 'src/render/index.html'),
},
},
},
resolve: {
alias: {
'@': join(__dirname, 'src/render'),
},
},
server: {
host: '127.0.0.1',
port: 3333,
// 设为 true 时若端口已被占用则会直接退出,而不是尝试下一个可用端口
strictPort: true,
open: '',
proxy: {},
},
})