diff --git a/lib/arco-design-plugin/less.js b/lib/arco-design-plugin/less.js index 044754bece8ab8070f9a2ae4156b6c2ce64cbf35..7ebe2a9a10223148ce9236db69a69579209ea51b 100644 --- a/lib/arco-design-plugin/less.js +++ b/lib/arco-design-plugin/less.js @@ -47,8 +47,9 @@ function modifyCssConfig(pkgName, config, theme, modifyVars, varsInjectScope) { // arco component style const componentName = (0, utils_1.pathMatch)(filename, config_1.componentLessMatchers); if (componentName) { - if ((0, utils_1.getThemeComponentList)(theme).includes(componentName)) { - src += `; @import '${theme}/components/${componentName}/index.less';`; + const name = (0, utils_1.getThemeComponentList)(theme).find(item => item.toLowerCase() === componentName.toLowerCase()); + if (name) { + src += `; @import '${theme}/components/${name}/index.less';`; } } } diff --git a/types/arco-design-plugin/config.d.ts b/types/arco-design-plugin/config.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b2c2fde5ed5f668fda7b1e5d053431b57fbacc61 --- /dev/null +++ b/types/arco-design-plugin/config.d.ts @@ -0,0 +1,12 @@ +declare type Matchers = [string, number?]; +export declare const libraryName = "@arco-design/web-vue"; +export declare const iconCjsListMatchers: Matchers; +export declare const iconComponentMatchers: Matchers; +export declare const lessMatchers: Matchers; +export declare const fullLessMatchers: Matchers; +export declare const globalLessMatchers: Matchers; +export declare const componentLessMatchers: Matchers; +export declare const fullCssMatchers: Matchers; +export declare const globalCssMatchers: Matchers; +export declare const componentCssMatchers: Matchers; +export {}; diff --git a/types/arco-design-plugin/icon.d.ts b/types/arco-design-plugin/icon.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5d79bd1d828b5450f40b3cad27a359bf7310b05 --- /dev/null +++ b/types/arco-design-plugin/icon.d.ts @@ -0,0 +1,3 @@ +import type { UserConfig } from 'vite'; +export declare function loadIcon(id: string, iconBox: string, iconBoxLib: any): string; +export declare function modifyIconConfig(config: UserConfig, iconBox: string, iconBoxLib: any): void; diff --git a/types/arco-design-plugin/index.d.ts b/types/arco-design-plugin/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..15a51fb4900ca162d41381bbf8d78d5c060d6b2b --- /dev/null +++ b/types/arco-design-plugin/index.d.ts @@ -0,0 +1,14 @@ +import type { Plugin } from 'vite'; +declare type Vars = Record; +declare type Style = boolean | 'css'; +interface PluginOption { + theme?: string; + iconBox?: string; + modifyVars?: Vars; + style?: Style; + varsInjectScope?: (string | RegExp)[]; + componentPrefix?: string; + iconPrefix?: string; +} +export default function vitePluginArcoImport(options?: PluginOption): Plugin; +export {}; diff --git a/types/arco-design-plugin/less.d.ts b/types/arco-design-plugin/less.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9d9f72bbc99d817b7d5809617e3c7d4795d464d --- /dev/null +++ b/types/arco-design-plugin/less.d.ts @@ -0,0 +1,4 @@ +import type { UserConfig } from 'vite'; +declare type Vars = Record; +export declare function modifyCssConfig(pkgName: string, config: UserConfig, theme: string, modifyVars: Vars, varsInjectScope: (string | RegExp)[]): void; +export {}; diff --git a/types/arco-design-plugin/transform.d.ts b/types/arco-design-plugin/transform.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d07ea4f8be0f3d1eeca074a94b91525a5f65200b --- /dev/null +++ b/types/arco-design-plugin/transform.d.ts @@ -0,0 +1,21 @@ +declare type TransformedResult = undefined | { + code: string; + map: any; +}; +declare type Style = boolean | 'css'; +export declare function transformCssFile({ id, theme, }: { + code: string; + id: string; + theme: string; +}): TransformedResult; +export declare function transformJsFiles({ code, id, theme, style, styleOptimization, sourceMaps, componentPrefix, iconPrefix, }: { + code: string; + id: string; + theme?: string; + style: Style; + styleOptimization: boolean; + sourceMaps: boolean; + componentPrefix: string; + iconPrefix: string; +}): TransformedResult; +export {}; diff --git a/types/arco-design-plugin/utils.d.ts b/types/arco-design-plugin/utils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7887f605a8c8799faeae754bd683d01ac59022ad --- /dev/null +++ b/types/arco-design-plugin/utils.d.ts @@ -0,0 +1,27 @@ +import { NodePath } from '@babel/traverse'; +declare type Style = boolean | 'css'; +export declare function readFileStrSync(path: string): false | string; +export declare function getThemeComponentList(theme: string): string[]; +export declare const parse2PosixPath: (path: string) => string; +export declare function pathMatch(path: string, conf: [string | RegExp, number?]): false | string; +export declare function parseInclude2RegExp(include?: (string | RegExp)[], context?: string): false | RegExp; +export declare function isPascalCase(name: string): boolean; +export declare function kebabCaseToPascalCase(name: string): string; +export declare function getComponentConfig(libraryName: string, componentName: string): { + dir: string; + styleDir?: string; +}; +export declare function importComponent({ path, componentDir, componentName, }: { + path: NodePath; + componentDir: string; + componentName: string; +}): void; +export declare function importStyle({ componentDirs, styleOptimization, path, style, theme, libraryName, }: { + componentDirs: string[]; + styleOptimization: boolean; + path: NodePath; + style: Style; + theme: string; + libraryName: string; +}): void; +export {}; diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f687a16712941d540334e8252e94d4957c17d8ee --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,3 @@ +import vitePluginForArco from './arco-design-plugin'; +export default vitePluginForArco; +export { vitePluginForArco };