Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: overwrite plugin-vue define with user define option #6072

Merged
merged 4 commits into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/plugin-vue-jsx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,21 @@ function vueJsxPlugin(options = {}) {
name: 'vite:vue-jsx',

config(config) {
const optionsApi = config.define
? config.define.__VUE_OPTIONS_API__
: undefined
const devTools = config.define
? config.define.__VUE_PROD_DEVTOOLS__
: undefined
return {
// only apply esbuild to ts files
// since we are handling jsx and tsx now
esbuild: {
include: /\.ts$/
},
define: {
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
...config.define
__VUE_OPTIONS_API__: optionsApi != null ? optionsApi : true,
__VUE_PROD_DEVTOOLS__: devTools != null ? devTools : false
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
config(config) {
return {
define: {
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false
__VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true,
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false
},
ssr: {
external: ['vue', '@vue/server-renderer']
Expand Down