From 2a4c3514a2c3356f381b31c738dd1a8c8490fc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=81=AA=E5=B0=8F=E9=99=88?= Date: Thu, 11 Jul 2024 10:28:21 +0800 Subject: [PATCH] feat: add mako types (#12553) * feat: add mako types * chore: remove moduleIdStrategy * docs: config mako --- docs/docs/docs/api/config.md | 8 +++++++ packages/preset-umi/src/features/mako/mako.ts | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/docs/docs/docs/api/config.md b/docs/docs/docs/api/config.md index ee855056eb10..c68c613ffd20 100644 --- a/docs/docs/docs/api/config.md +++ b/docs/docs/docs/api/config.md @@ -963,6 +963,14 @@ legacy: {} links: [{ href: '/foo.css', rel: 'preload' }], ``` +## mako 4.3.2+ + +- 类型: `{ plugins?: Array<{ load?: ((...args: any[]) => unknown) | undefined; generateEnd?: ((...args: any[]) => unknown) | undefined; }> | undefined; px2rem?: { root?: number | undefined; propBlackList?: Array | undefined; propWhiteList?: Array | undefined; selectorBlackList?: Array | undefined; selectorWhiteList?: Array | undefined; selectorDoubleList?: Array | undefined; } | undefined; experimental?: { webpackSyntaxValidate?: Array | undefined; } | undefined; flexBugs?: boolean | undefined; moduleIdStrategy?: string | undefined; optimization?: { skipModules?: boolean | undefined; } | undefined; }` +- 默认值: `{}` + +使用 [mako](https://makojs.dev/) 用于编译以显著提高构建速度。 +通过配置以启用这个能力,配置将传递给mako。这里只提供了一些常用的配置,更多的配置可以在 `mako.config.json` 文件中设置。有关更多信息,请参阅[mako-config文档](https://makojs.dev/docs/config)。 + ## manifest - 类型:`{ fileName: string; basePath: string }` diff --git a/packages/preset-umi/src/features/mako/mako.ts b/packages/preset-umi/src/features/mako/mako.ts index 71e3b3d1be28..d006b33874ae 100644 --- a/packages/preset-umi/src/features/mako/mako.ts +++ b/packages/preset-umi/src/features/mako/mako.ts @@ -17,6 +17,27 @@ export default (api: IApi) => { }) .partial(), ), + px2rem: zod + .object({ + root: zod.number(), + propBlackList: zod.array(zod.string()), + propWhiteList: zod.array(zod.string()), + selectorBlackList: zod.array(zod.string()), + selectorWhiteList: zod.array(zod.string()), + selectorDoubleList: zod.array(zod.string()), + }) + .partial(), + experimental: zod + .object({ + webpackSyntaxValidate: zod.array(zod.string()), + }) + .partial(), + flexBugs: zod.boolean(), + optimization: zod + .object({ + skipModules: zod.boolean(), + }) + .partial(), }) .partial(); },