1
1
import { default as vuePlugin } from '@vitejs/plugin-vue'
2
2
import type { App } from '@vuepress/core'
3
- import type { InlineConfig } from 'vite'
3
+ import { type InlineConfig , mergeConfig } from 'vite'
4
4
import {
5
5
constantsReplacementPlugin ,
6
6
mainPlugin ,
@@ -19,18 +19,22 @@ export const resolveViteConfig = async ({
19
19
isBuild : boolean
20
20
isServer : boolean
21
21
} ) : Promise < InlineConfig > => {
22
- return {
23
- clearScreen : false ,
24
- configFile : false ,
25
- logLevel : ! isBuild || app . env . isDebug ? 'info' : 'warn' ,
26
- esbuild : {
27
- charset : 'utf8' ,
22
+ return mergeConfig (
23
+ {
24
+ clearScreen : false ,
25
+ configFile : false ,
26
+ logLevel : ! isBuild || app . env . isDebug ? 'info' : 'warn' ,
27
+ esbuild : {
28
+ charset : 'utf8' ,
29
+ } ,
30
+ plugins : [
31
+ vuePlugin ( options . vuePluginOptions ) ,
32
+ constantsReplacementPlugin ( app ) ,
33
+ mainPlugin ( { app, isBuild, isServer } ) ,
34
+ userConfigPlugin ( options ) ,
35
+ ] ,
28
36
} ,
29
- plugins : [
30
- vuePlugin ( options . vuePluginOptions ) ,
31
- constantsReplacementPlugin ( app ) ,
32
- mainPlugin ( { app, isBuild, isServer } ) ,
33
- userConfigPlugin ( options ) ,
34
- ] ,
35
- }
37
+ // some vite options would not take effect inside a plugin, so we still need to merge them here in addition to userConfigPlugin
38
+ options . viteOptions ?? { }
39
+ )
36
40
}
0 commit comments