Skip to content

Commit

Permalink
feat: hd support mako
Browse files Browse the repository at this point in the history
feat: hd support mako
  • Loading branch information
xiaohuoni authored Jul 30, 2024
2 parents 28a1746 + 8373c1c commit 171582f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-ties-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alita/plugins': patch
---

feat: hd support mako
32 changes: 26 additions & 6 deletions packages/plugins/src/hd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down

0 comments on commit 171582f

Please sign in to comment.