diff --git a/.changeset/yellow-ties-yell.md b/.changeset/yellow-ties-yell.md new file mode 100644 index 00000000..1bc91f41 --- /dev/null +++ b/.changeset/yellow-ties-yell.md @@ -0,0 +1,5 @@ +--- +'@alita/plugins': patch +--- + +feat: hd support mako diff --git a/packages/plugins/src/hd.ts b/packages/plugins/src/hd.ts index 8c6e7d74..e7d19894 100644 --- a/packages/plugins/src/hd.ts +++ b/packages/plugins/src/hd.ts @@ -31,21 +31,41 @@ export default (api: AlitaApi) => { api.modifyDefaultConfig((config) => { const draftConfig = config; - const { theme, px2rem: configPx2rem } = api.userConfig?.hd || {}; + const { hd = {}, mako } = api.userConfig || {}; + + const { theme, px2rem: configPx2rem } = hd || {}; draftConfig.theme = { ...(draftConfig.theme || {}), '@hd': '2px', ...(theme || {}), }; - draftConfig.extraPostCSSPlugins = [ - ...(draftConfig.extraPostCSSPlugins || []), - px2rem({ + if (!mako) { + draftConfig.extraPostCSSPlugins = [ + ...(draftConfig.extraPostCSSPlugins || []), + px2rem({ + rootValue: 100, + minPixelValue: 2, + selectorDoubleRemList: [/^.adm-/, /^.ant-/, /^\:root/], + ...(configPx2rem || {}), + }), + ]; + } else if (!mako?.px2rem) { + const px2remConfig = { rootValue: 100, minPixelValue: 2, selectorDoubleRemList: [/^.adm-/, /^.ant-/, /^\:root/], ...(configPx2rem || {}), - }), - ]; + }; + draftConfig.mako = mako; + draftConfig.mako.px2rem = { + ...px2remConfig, + // 将正则转成字符串 + selectorDoubleList: px2remConfig.selectorDoubleRemList.map( + (i: string) => `${i}`.replaceAll('/', ''), + ), + }; + } + return draftConfig; });