@vitejs/plugin-vue-jsx npm

Provides Vue 3 JSX & TSX support with HMR.

  1. // vite.config.js
  2. import vueJsx from '@vitejs/plugin-vue-jsx'
  3. export default {
  4. plugins: [
  5. vueJsx({
  6. // options are passed on to @vue/babel-plugin-jsx
  7. })
  8. ]
  9. }

Options

See @vue/babel-plugin-jsx.

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

  1. import { defineComponent } from 'vue'
  2. // named exports w/ variable declaration: ok
  3. export const Foo = defineComponent(...)
  4. // named exports referencing variable declaration: ok
  5. const Bar = defineComponent(...)
  6. export { Bar }
  7. // default export call: ok
  8. export default defineComponent(...)
  9. // default export referencing variable declaration: ok
  10. const Baz = defineComponent(...)
  11. export default Baz

Non-supported patterns

  1. // not using `defineComponent` call
  2. export const Bar = { ... }
  3. // not exported
  4. const Foo = defineComponent(...)