UNPKG

@lcap/builder

Version:
163 lines (162 loc) 6.33 kB
export type BuildMode = 'production' | 'watch' | 'staging'; export interface BuildIdeOptions { configFile?: string; entry?: string; outDir?: string; setters?: { rootPath: string; entries: Record<string, string>; }; } export interface Dependency { name: string; rootPath: string; config: (component: any) => any; } export interface ThemeOptions { themeVarCssPath: string; themeComponentFolder: string; type: string; previewPages: Array<{ name: string; title: string; viewport?: { width: number; height: number; }; }>; oldCssVarPath?: string; components: Array<{ group: string; title: string; name: string; [key: string]: any; }>; findThemeType?: 'theme' | 'component'; dependencies?: Dependency[]; } export interface LcapThemeOptions extends Partial<ThemeOptions> { themePreviewEntry?: string; } export interface LcapMetaOptions { rootPath: string; type: 'extension' | 'nasl.ui'; framework: 'react' | 'vue2' | 'taro' | 'vue3'; } export interface BuildModulesOptions extends LcapMetaOptions { outDir: string; entries?: { [key: string]: string; }; external?: (string | RegExp)[]; moduleSideEffects?: (id: string, external: boolean) => boolean; tsconfigPath?: string; addDepExternal?: boolean; } export type DepComponent = { /** 依赖的组件样式重置过来时,是否仍为根节点。默认为 false */ stillRoot: boolean; /** 依赖的组件名称 */ componentName: string; cssInfo?: FinalComponentCSSInfo; }; export interface LcapBuildOptions extends LcapMetaOptions { assetsPublicPath?: string; frameworkUI?: string; components?: Array<{ group: string; title: string; name: string; [key: string]: any; }>; i18n?: boolean | { [lang: string]: string; }; theme: LcapThemeOptions; ide?: BuildIdeOptions; modules?: boolean | Partial<Omit<BuildModulesOptions, keyof LcapMetaOptions>>; destDir: string; pnpm?: boolean; /** * 基础组件是否不打包, * - true: 不打包 * - false: 打包 * - 'auto': 自动处理, 默认值, 基础组件支持模块化加载时打包 */ lcapUIExternal?: true | 'auto'; dependencies?: Dependency[]; reportCSSInfo?: { enabled: true; verbose?: true; extraComponentMap?: Record<string, { /** * ### 补充组件相关的选择器前缀 * key 为前缀名,value 表示是否为根节点 * * 一般有以下情况: * - build 后的 CSS 中有组件信息,但前缀不匹配组件名,需要手动补充前缀 * @example: 表格需要补充 u-table 前缀的选择器:UTableView: { selectorPrefixMap: { 'u-table': false } } * - 组件前缀不是默认的根节点,需要切换 * @example: 目录组件根节点是 _wrap,需要互换:UToc: { selectorPrefixMap: { 'u-toc': false, 'u-toc_wrap': true } } * - 优先让子组件匹配选择器 * @example: DropDownItem 不是按主组件的命名方式,按照 BEM 会识别成主组件的节点,需要显式给子组件声明出来:ElDropdownItem: { selectorPrefixMap: { 'el-dropdown-menu__item': true } } */ selectorPrefixMap?: Record<string, boolean>; /** * ### 补充主选择器 * key 为选择器,value 表示是否为根节点 * * 一般是因为 rule 是空的,build 后的 CSS 被压缩没了。需要手动补充选择器信息 * @example: 表单本身没有样式,UForm: { mainSelectorMap: { "[class*=u-form___]": true } } */ mainSelectorMap?: Record<string, boolean>; /** * @deprecated * ### 额外补充依赖组件 * 比如 UTreeSelectNew依赖了UTreeViewNew,需要补充UTreeViewNew */ depComponents?: Array<string | DepComponent>; /** * ### 额外补充依赖组件 * depComponents 的另一种写法 * * key 为组件名,value 表示该依赖组件的顶层是否同为根节点 */ depComponentMap?: Record<string, boolean | FinalComponentCSSInfo | DepComponent>; /** * ### 继承其他组件的 CSS 信息 */ extends: FinalComponentCSSInfo; /** * 需要隐藏的选择器前缀列表 */ hideSelectorPrefixes?: Array<string>; /** * 需要隐藏的选择器正则列表 */ hideSelectorRegexps?: Array<RegExp>; }>; /** * 忽略警告列表规则 */ warningIgnore?: RegExp[]; inferSelectorComponentName?: (selector: string, componentNameMap: Record<string, string | undefined>) => string | undefined; isSelectorStartRoot?: (selector: string, componentName: string, parentName: string | undefined) => boolean; }; } export declare const SupportedCSSProperties: ("backgroundColor" | "color" | "fontSize" | "borderTopColor" | "borderRightColor" | "borderBottomColor" | "borderLeftColor" | "borderTopWidth" | "borderRightWidth" | "borderBottomWidth" | "borderLeftWidth" | "borderTopStyle" | "borderRightStyle" | "borderBottomStyle" | "borderLeftStyle" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderBottomRightRadius" | "borderBottomLeftRadius" | "width" | "height" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft")[]; export type SupportedCSSProperty = (typeof SupportedCSSProperties)[number]; export interface CSSValue { defaultValue: string; important?: boolean; } export interface CSSRule<V = CSSValue> { selector: string; isStartRoot: boolean; description: string; parsedStyle?: Partial<Record<SupportedCSSProperty, V>>; } export interface FinalComponentCSSInfo { cssRules: CSSRule[]; mainSelectorMap: Record<string, boolean>; }