Skip to content

Commit 171582f

Browse files
authored
feat: hd support mako
feat: hd support mako
2 parents 28a1746 + 8373c1c commit 171582f

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

.changeset/yellow-ties-yell.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@alita/plugins': patch
3+
---
4+
5+
feat: hd support mako

packages/plugins/src/hd.ts

+26-6
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,41 @@ export default (api: AlitaApi) => {
3131

3232
api.modifyDefaultConfig((config) => {
3333
const draftConfig = config;
34-
const { theme, px2rem: configPx2rem } = api.userConfig?.hd || {};
34+
const { hd = {}, mako } = api.userConfig || {};
35+
36+
const { theme, px2rem: configPx2rem } = hd || {};
3537
draftConfig.theme = {
3638
...(draftConfig.theme || {}),
3739
'@hd': '2px',
3840
...(theme || {}),
3941
};
40-
draftConfig.extraPostCSSPlugins = [
41-
...(draftConfig.extraPostCSSPlugins || []),
42-
px2rem({
42+
if (!mako) {
43+
draftConfig.extraPostCSSPlugins = [
44+
...(draftConfig.extraPostCSSPlugins || []),
45+
px2rem({
46+
rootValue: 100,
47+
minPixelValue: 2,
48+
selectorDoubleRemList: [/^.adm-/, /^.ant-/, /^\:root/],
49+
...(configPx2rem || {}),
50+
}),
51+
];
52+
} else if (!mako?.px2rem) {
53+
const px2remConfig = {
4354
rootValue: 100,
4455
minPixelValue: 2,
4556
selectorDoubleRemList: [/^.adm-/, /^.ant-/, /^\:root/],
4657
...(configPx2rem || {}),
47-
}),
48-
];
58+
};
59+
draftConfig.mako = mako;
60+
draftConfig.mako.px2rem = {
61+
...px2remConfig,
62+
// 将正则转成字符串
63+
selectorDoubleList: px2remConfig.selectorDoubleRemList.map(
64+
(i: string) => `${i}`.replaceAll('/', ''),
65+
),
66+
};
67+
}
68+
4969
return draftConfig;
5070
});
5171

0 commit comments

Comments
 (0)