Skip to content

Commit

Permalink
fix: allow overwriting define options in vue & vue-jsx plugins (#6072)
Browse files Browse the repository at this point in the history
  • Loading branch information
ydcjeff authored Dec 12, 2021
1 parent 1487223 commit 5f3f6b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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 @@ -130,8 +130,8 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
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

0 comments on commit 5f3f6b7

Please sign in to comment.