index.d.cts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import { ViteDevServer, Plugin } from 'vite';
  2. import * as _compiler from 'vue/compiler-sfc';
  3. import { SFCScriptCompileOptions, SFCTemplateCompileOptions, SFCStyleCompileOptions } from 'vue/compiler-sfc';
  4. interface VueQuery {
  5. vue?: boolean;
  6. src?: string;
  7. type?: 'script' | 'template' | 'style' | 'custom';
  8. index?: number;
  9. lang?: string;
  10. raw?: boolean;
  11. url?: boolean;
  12. scoped?: boolean;
  13. id?: string;
  14. }
  15. declare function parseVueRequest(id: string): {
  16. filename: string;
  17. query: VueQuery;
  18. };
  19. interface Options {
  20. include?: string | RegExp | (string | RegExp)[];
  21. exclude?: string | RegExp | (string | RegExp)[];
  22. /**
  23. * In Vite, this option follows Vite's config.
  24. */
  25. isProduction?: boolean;
  26. script?: Partial<Omit<SFCScriptCompileOptions, 'id' | 'isProd' | 'inlineTemplate' | 'templateOptions' | 'sourceMap' | 'genDefaultAs' | 'customElement' | 'defineModel' | 'propsDestructure'>> & {
  27. /**
  28. * @deprecated defineModel is now a stable feature and always enabled if
  29. * using Vue 3.4 or above.
  30. */
  31. defineModel?: boolean;
  32. /**
  33. * @deprecated moved to `features.propsDestructure`.
  34. */
  35. propsDestructure?: boolean;
  36. };
  37. template?: Partial<Omit<SFCTemplateCompileOptions, 'id' | 'source' | 'ast' | 'filename' | 'scoped' | 'slotted' | 'isProd' | 'inMap' | 'ssr' | 'ssrCssVars' | 'preprocessLang'>>;
  38. style?: Partial<Omit<SFCStyleCompileOptions, 'filename' | 'id' | 'isProd' | 'source' | 'scoped' | 'cssDevSourcemap' | 'postcssOptions' | 'map' | 'postcssPlugins' | 'preprocessCustomRequire' | 'preprocessLang' | 'preprocessOptions'>>;
  39. /**
  40. * Use custom compiler-sfc instance. Can be used to force a specific version.
  41. */
  42. compiler?: typeof _compiler;
  43. /**
  44. * Requires @vitejs/plugin-vue@^5.1.0
  45. */
  46. features?: {
  47. /**
  48. * Enable reactive destructure for `defineProps`.
  49. * - Available in Vue 3.4 and later.
  50. * - **default:** `false` in Vue 3.4 (**experimental**), `true` in Vue 3.5+
  51. */
  52. propsDestructure?: boolean;
  53. /**
  54. * Transform Vue SFCs into custom elements.
  55. * - `true`: all `*.vue` imports are converted into custom elements
  56. * - `string | RegExp`: matched files are converted into custom elements
  57. * - **default:** /\.ce\.vue$/
  58. */
  59. customElement?: boolean | string | RegExp | (string | RegExp)[];
  60. /**
  61. * Set to `false` to disable Options API support and allow related code in
  62. * Vue core to be dropped via dead-code elimination in production builds,
  63. * resulting in smaller bundles.
  64. * - **default:** `true`
  65. */
  66. optionsAPI?: boolean;
  67. /**
  68. * Set to `true` to enable devtools support in production builds.
  69. * Results in slightly larger bundles.
  70. * - **default:** `false`
  71. */
  72. prodDevtools?: boolean;
  73. /**
  74. * Set to `true` to enable detailed information for hydration mismatch
  75. * errors in production builds. Results in slightly larger bundles.
  76. * - **default:** `false`
  77. */
  78. prodHydrationMismatchDetails?: boolean;
  79. };
  80. /**
  81. * @deprecated moved to `features.customElement`.
  82. */
  83. customElement?: boolean | string | RegExp | (string | RegExp)[];
  84. }
  85. interface ResolvedOptions extends Options {
  86. compiler: typeof _compiler;
  87. root: string;
  88. sourceMap: boolean;
  89. cssDevSourcemap: boolean;
  90. devServer?: ViteDevServer;
  91. devToolsEnabled?: boolean;
  92. }
  93. interface Api {
  94. get options(): ResolvedOptions;
  95. set options(value: ResolvedOptions);
  96. version: string;
  97. }
  98. declare function vuePlugin(rawOptions?: Options): Plugin<Api>;
  99. export { type Api, type Options, type ResolvedOptions, type VueQuery, vuePlugin as default, parseVueRequest };