版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # @vitejs/plugin-vue-jsx [![npm](https://img.shields.io/npm/v/@vitejs/plugin-vue-jsx.svg)](https://npmjs.com/package/@vitejs/plugin-vue-jsx)
  2. Provides Vue 3 JSX & TSX support with HMR.
  3. ```js
  4. // vite.config.js
  5. import vueJsx from '@vitejs/plugin-vue-jsx'
  6. export default {
  7. plugins: [
  8. vueJsx({
  9. // options are passed on to @vue/babel-plugin-jsx
  10. }),
  11. ],
  12. }
  13. ```
  14. ## Options
  15. ### include
  16. Type: `(string | RegExp)[] | string | RegExp | null`
  17. Default: `/\.[jt]sx$/`
  18. A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on.
  19. ### exclude
  20. Type: `(string | RegExp)[] | string | RegExp | null`
  21. Default: `undefined`
  22. A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files to be ignored by the plugin.
  23. > See [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next) for other options.
  24. ## HMR Detection
  25. This plugin supports HMR of Vue JSX components. The detection requirements are:
  26. - The component must be exported.
  27. - The component must be declared by calling `defineComponent` via a root-level statement, either variable declaration or export declaration.
  28. ### Supported patterns
  29. ```jsx
  30. import { defineComponent } from 'vue'
  31. // named exports w/ variable declaration: ok
  32. export const Foo = defineComponent({})
  33. // named exports referencing variable declaration: ok
  34. const Bar = defineComponent({ render() { return <div>Test</div> }})
  35. export { Bar }
  36. // default export call: ok
  37. export default defineComponent({ render() { return <div>Test</div> }})
  38. // default export referencing variable declaration: ok
  39. const Baz = defineComponent({ render() { return <div>Test</div> }})
  40. export default Baz
  41. ```
  42. ### Non-supported patterns
  43. ```jsx
  44. // not using `defineComponent` call
  45. export const Bar = { ... }
  46. // not exported
  47. const Foo = defineComponent(...)
  48. ```