Skip to content

Commit 998eb94

Browse files
committed
fix(bundler-vite): fix regression of vite options merging (close #1184)
1 parent 78f737c commit 998eb94

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { default as vuePlugin } from '@vitejs/plugin-vue'
22
import type { App } from '@vuepress/core'
3-
import type { InlineConfig } from 'vite'
3+
import { type InlineConfig, mergeConfig } from 'vite'
44
import {
55
constantsReplacementPlugin,
66
mainPlugin,
@@ -19,18 +19,22 @@ export const resolveViteConfig = async ({
1919
isBuild: boolean
2020
isServer: boolean
2121
}): 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+
],
2836
},
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+
)
3640
}

0 commit comments

Comments
 (0)