@vitejs/plugin-vue2-jsx
Provides Vue 2 JSX & TSX support with HMR.
import vueJsx from '@vitejs/plugin-vue2-jsx'
export default {
plugins: [
vueJsx({
})
]
}
Options
include
Type: (string | RegExp)[] | string | RegExp | null
Default: /\.[jt]sx$/
A picomatch pattern, or array of patterns, which specifies the files the plugin should operate on.
exclude
Type: (string | RegExp)[] | string | RegExp | null
Default: undefined
A picomatch pattern, or array of patterns, which specifies the files to be ignored by the plugin.
See @vue/babel-preset-jsx for other options.
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
import { defineComponent } from 'vue'
export const Foo = defineComponent({})
const Bar = defineComponent({ render() { return <div>Test</div> }})
export { Bar }
export default defineComponent({ render() { return <div>Test</div> }})
const Baz = defineComponent({ render() { return <div>Test</div> }})
export default Baz
Non-supported patterns
export const Bar = { ... }
const Foo = defineComponent(...)
Unfinished Features
- SSR support
- Share the same HMR runtime with
@vitejs/plugin-vue2