-
Notifications
You must be signed in to change notification settings - Fork 922
/
Copy pathresolveViteConfig.ts
44 lines (43 loc) · 1.16 KB
/
resolveViteConfig.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
import type { App } from '@vuepress/core'
import type { InlineConfig } from 'vite'
import { mergeConfig } from 'vite'
import {
vuepressBuildPlugin,
vuepressConfigPlugin,
vuepressDevPlugin,
vuepressMarkdownPlugin,
vuepressUserConfigPlugin,
vuepressVuePlugin,
} from './plugins/index.js'
import type { ViteBundlerOptions } from './types.js'
export const resolveViteConfig = ({
app,
options,
isBuild,
isServer,
}: {
app: App
options: ViteBundlerOptions
isBuild: boolean
isServer: boolean
}): InlineConfig =>
mergeConfig(
{
clearScreen: false,
configFile: false,
logLevel: !isBuild || app.env.isDebug ? 'info' : 'warn',
esbuild: {
charset: 'utf8',
},
plugins: [
vuepressConfigPlugin({ app, isBuild, isServer }),
vuepressMarkdownPlugin({ app }),
vuepressDevPlugin({ app }),
vuepressBuildPlugin({ isServer }),
vuepressVuePlugin({ options }),
vuepressUserConfigPlugin({ options }),
],
},
// some vite options would not take effect inside a plugin, so we still need to merge them here in addition to userConfigPlugin
options.viteOptions ?? {},
)