vite.config.macros.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import type { PluginOption } from 'vite'
  2. import vuePlugin from '@vitejs/plugin-vue'
  3. import vueJsx from '@vitejs/plugin-vue-jsx'
  4. import DefinePropsRefs from '@vue-macros/define-props-refs/vite'
  5. import DefineProps from '@vue-macros/define-props/vite'
  6. import ReactivityTransform from '@vue-macros/reactivity-transform/vite'
  7. export default (): PluginOption[] => ([
  8. vuePlugin({
  9. template: {
  10. compilerOptions: {
  11. isCustomElement: (tag: string) => ['def'].includes(tag),
  12. },
  13. },
  14. }),
  15. vueJsx(),
  16. /**
  17. * Reactivity Transform
  18. * @description 响应性语法糖
  19. * @see https://vue-macros.sxzz.moe/zh-CN/features/reactivity-transform.html
  20. */
  21. ReactivityTransform(),
  22. /**
  23. * defineProps
  24. * @description 使用 $defineProps 可以正确地解构 props 的类型
  25. * @see https://vue-macros.sxzz.moe/zh-CN/macros/define-props.html
  26. */
  27. DefineProps(),
  28. /**
  29. * definePropsRefs
  30. * @description 从 defineProps 中将返回 refs 而不是 reactive 对象,可以在不丢失响应式的情况下解构 props
  31. * @see https://vue-macros.sxzz.moe/zh-CN/macros/define-props-refs.html
  32. */
  33. DefinePropsRefs(),
  34. ])