index.d.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. }
  14. declare function parseVueRequest(id: string): {
  15. filename: string;
  16. query: VueQuery;
  17. };
  18. interface Options {
  19. include?: string | RegExp | (string | RegExp)[];
  20. exclude?: string | RegExp | (string | RegExp)[];
  21. isProduction?: boolean;
  22. script?: Partial<Pick<SFCScriptCompileOptions, 'babelParserPlugins'>>;
  23. template?: Partial<Pick<SFCTemplateCompileOptions, 'compiler' | 'compilerOptions' | 'preprocessOptions' | 'preprocessCustomRequire' | 'transformAssetUrls'>>;
  24. style?: Partial<Pick<SFCStyleCompileOptions, 'trim'>>;
  25. /**
  26. * Transform Vue SFCs into custom elements.
  27. * - `true`: all `*.vue` imports are converted into custom elements
  28. * - `string | RegExp`: matched files are converted into custom elements
  29. *
  30. * @default /\.ce\.vue$/
  31. */
  32. customElement?: boolean | string | RegExp | (string | RegExp)[];
  33. /**
  34. * Enable Vue reactivity transform (experimental).
  35. * https://vuejs.org/guide/extras/reactivity-transform.html
  36. * - `true`: transform will be enabled for all vue,js(x),ts(x) files except
  37. * those inside node_modules
  38. * - `string | RegExp`: apply to vue + only matched files (will include
  39. * node_modules, so specify directories if necessary)
  40. * - `false`: disable in all cases
  41. *
  42. * @default false
  43. */
  44. reactivityTransform?: boolean | string | RegExp | (string | RegExp)[];
  45. /**
  46. * Use custom compiler-sfc instance. Can be used to force a specific version.
  47. */
  48. compiler?: typeof _compiler;
  49. }
  50. interface ResolvedOptions extends Options {
  51. compiler: typeof _compiler;
  52. root: string;
  53. sourceMap: boolean;
  54. cssDevSourcemap: boolean;
  55. devServer?: ViteDevServer;
  56. devToolsEnabled?: boolean;
  57. }
  58. declare function vuePlugin(rawOptions?: Options): Plugin;
  59. export { Options, ResolvedOptions, VueQuery, vuePlugin as default, parseVueRequest };