-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,56 @@ | ||
# @vitejs/plugin-vue-jsx | ||
|
||
Provides optimized Vue 3 JSX support via [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next). | ||
Provides Vue 3 JSX & TSX support with HMR. | ||
|
||
```js | ||
// vite.config.js | ||
import vueJsx from '@vitejs/plugin-vue-jsx' | ||
|
||
export default { | ||
plugins: [vueJsx({ | ||
// options are passed on to @vue/babel-plugin-jsx | ||
})] | ||
plugins: [ | ||
vueJsx({ | ||
// options are passed on to @vue/babel-plugin-jsx | ||
}) | ||
] | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
See [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next). | ||
## HMR Detection | ||
|
||
This plugin supports HMR of Vue JSX components. The detection requirements are: | ||
|
||
- The component must be exported. | ||
- The component must be declared by calling `defineComponent` via a root-level statement, either variable declaration or export declaration. | ||
|
||
### Supported patterns | ||
|
||
```jsx | ||
import { defineComponent } from 'vue' | ||
|
||
// named exports w/ variable declaration: ok | ||
export const Foo = defineComponent(...) | ||
|
||
// named exports referencing vairable declaration: ok | ||
const Bar = defineComponent(...) | ||
export { Bar } | ||
|
||
// default export call: ok | ||
export default defineComponent(...) | ||
|
||
// default export referencing variable declaration: ok | ||
const Baz = defineComponent(...) | ||
export default Baz | ||
``` | ||
|
||
### Non-supported patterns | ||
|
||
```jsx | ||
// not using `defineComponent` call | ||
export const Bar = { ... } | ||
|
||
// not exported | ||
const Foo = defineComponent(...) | ||
``` |