index.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { Plugin } from 'vite';
  2. declare type RegOptions = string | RegExp | (string | RegExp)[] | null | undefined;
  3. interface Lib {
  4. importTest?: RegExp;
  5. /**
  6. * Dependent library name
  7. */
  8. libraryName: string;
  9. /**
  10. * When the imported style file does not end with .css, it needs to be turned on
  11. * @default: false
  12. */
  13. esModule?: boolean;
  14. /**
  15. * Custom imported component style conversion
  16. */
  17. resolveStyle?: (name: string) => string;
  18. /**
  19. * There may be some component libraries that are not very standardized.
  20. * You can turn on this to ignore to determine whether the file exists. Prevent errors when importing non-existent css files.
  21. * Performance may be slightly reduced after it is turned on, but the impact is not significant
  22. * @default: false
  23. */
  24. ensureStyleFile?: boolean;
  25. /**
  26. * Customize imported component file name style conversion
  27. * @default: paramCase
  28. */
  29. libraryNameChangeCase?: LibraryNameChangeCase;
  30. /**
  31. * Whether to introduce base style
  32. */
  33. base?: string;
  34. }
  35. interface VitePluginOptions {
  36. include?: RegOptions;
  37. exclude?: RegOptions;
  38. /**
  39. * @default process.cwd()
  40. * @deprecated 1.2.0 is obsolete
  41. */
  42. root?: string;
  43. libs?: Lib[];
  44. resolves?: Lib[];
  45. }
  46. interface Source {
  47. opts: {
  48. libs: Lib[];
  49. cacheDir: string;
  50. };
  51. }
  52. declare type LibraryNameChangeCase = ChangeCaseType | ((name: string) => string);
  53. declare type ChangeCaseType = 'camelCase' | 'capitalCase' | 'constantCase' | 'dotCase' | 'headerCase' | 'noCase' | 'paramCase' | 'pascalCase' | 'pathCase' | 'sentenceCase' | 'snakeCase';
  54. declare function AntdResolve(): Lib;
  55. declare function AndDesignVueResolve(): Lib;
  56. declare function ElementPlusResolve(): Lib;
  57. declare function VantResolve(): Lib;
  58. declare function NutuiResolve(): Lib;
  59. declare function VxeTableResolve(): Lib;
  60. declare function createStyleImportPlugin(options: VitePluginOptions): Plugin;
  61. declare function transformImportVar(importStr: string): readonly string[];
  62. declare function getChangeCaseFileName(importedName: string, libraryNameChangeCase: LibraryNameChangeCase): string;
  63. export { AndDesignVueResolve, AntdResolve, ChangeCaseType, ElementPlusResolve, Lib, LibraryNameChangeCase, NutuiResolve, RegOptions, Source, VantResolve, VitePluginOptions, VxeTableResolve, createStyleImportPlugin, getChangeCaseFileName, transformImportVar };