Skip to content

Commit

Permalink
fix(bundler-vite): fix regression of vite options merging (close #1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Dec 9, 2022
1 parent 78f737c commit 998eb94
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions packages/bundler-vite/src/resolveViteConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { default as vuePlugin } from '@vitejs/plugin-vue'
import type { App } from '@vuepress/core'
import type { InlineConfig } from 'vite'
import { type InlineConfig, mergeConfig } from 'vite'
import {
constantsReplacementPlugin,
mainPlugin,
Expand All @@ -19,18 +19,22 @@ export const resolveViteConfig = async ({
isBuild: boolean
isServer: boolean
}): Promise<InlineConfig> => {
return {
clearScreen: false,
configFile: false,
logLevel: !isBuild || app.env.isDebug ? 'info' : 'warn',
esbuild: {
charset: 'utf8',
return mergeConfig(
{
clearScreen: false,
configFile: false,
logLevel: !isBuild || app.env.isDebug ? 'info' : 'warn',
esbuild: {
charset: 'utf8',
},
plugins: [
vuePlugin(options.vuePluginOptions),
constantsReplacementPlugin(app),
mainPlugin({ app, isBuild, isServer }),
userConfigPlugin(options),
],
},
plugins: [
vuePlugin(options.vuePluginOptions),
constantsReplacementPlugin(app),
mainPlugin({ app, isBuild, isServer }),
userConfigPlugin(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 ?? {}
)
}

0 comments on commit 998eb94

Please sign in to comment.