From 47443910ce1324bcbd6a6fc43e44a1c656c8fd88 Mon Sep 17 00:00:00 2001 From: xiaohuoni Date: Mon, 29 Jul 2024 18:02:37 +0800 Subject: [PATCH 1/2] feat: hd support mako --- packages/plugins/src/hd.ts | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) 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; }); From 8373c1c475682e5452c7bc1859bfe88b07fcacc9 Mon Sep 17 00:00:00 2001 From: xiaohuoni Date: Tue, 30 Jul 2024 09:28:40 +0800 Subject: [PATCH 2/2] chore: log --- .changeset/yellow-ties-yell.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/yellow-ties-yell.md 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