index.d.cts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. isProduction?: boolean;
  23. script?: Partial<Pick<SFCScriptCompileOptions, 'babelParserPlugins' | 'globalTypeFiles' | 'defineModel' | 'propsDestructure' | 'fs' | 'reactivityTransform' | 'hoistStatic'>>;
  24. template?: Partial<Pick<SFCTemplateCompileOptions, 'compiler' | 'compilerOptions' | 'preprocessOptions' | 'preprocessCustomRequire' | 'transformAssetUrls'>>;
  25. style?: Partial<Pick<SFCStyleCompileOptions, 'trim'>>;
  26. /**
  27. * Transform Vue SFCs into custom elements.
  28. * - `true`: all `*.vue` imports are converted into custom elements
  29. * - `string | RegExp`: matched files are converted into custom elements
  30. *
  31. * @default /\.ce\.vue$/
  32. */
  33. customElement?: boolean | string | RegExp | (string | RegExp)[];
  34. /**
  35. * Enable Vue reactivity transform (experimental).
  36. * https://vuejs.org/guide/extras/reactivity-transform.html
  37. * - `true`: transform will be enabled for all vue,js(x),ts(x) files except
  38. * those inside node_modules
  39. * - `string | RegExp`: apply to vue + only matched files (will include
  40. * node_modules, so specify directories if necessary)
  41. * - `false`: disable in all cases
  42. *
  43. * @deprecated the Reactivity Transform proposal has been dropped. This
  44. * feature will be removed from Vue core in 3.4. If you intend to continue
  45. * using it, disable this and switch to the [Vue Macros implementation](https://vue-macros.sxzz.moe/features/reactivity-transform.html).
  46. *
  47. * @default false
  48. */
  49. reactivityTransform?: boolean | string | RegExp | (string | RegExp)[];
  50. /**
  51. * Use custom compiler-sfc instance. Can be used to force a specific version.
  52. */
  53. compiler?: typeof _compiler;
  54. }
  55. interface ResolvedOptions extends Options {
  56. compiler: typeof _compiler;
  57. root: string;
  58. sourceMap: boolean;
  59. cssDevSourcemap: boolean;
  60. devServer?: ViteDevServer;
  61. devToolsEnabled?: boolean;
  62. }
  63. declare function vuePlugin(rawOptions?: Options): Plugin;
  64. export { type Options, type ResolvedOptions, type VueQuery, vuePlugin as default, parseVueRequest };