From ff46f60360e2d59a90091b0c7433de4c45f32641 Mon Sep 17 00:00:00 2001 From: PeachScript Date: Tue, 8 Dec 2020 18:02:10 +0800 Subject: [PATCH] fix(preset): umi default alias cannot working with integrated mode --- packages/preset-dumi/src/plugins/features/init.ts | 10 ++++++++++ packages/preset-dumi/src/routes/getRouteConfig.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/preset-dumi/src/plugins/features/init.ts b/packages/preset-dumi/src/plugins/features/init.ts index b7af55a36a..cff784eb51 100644 --- a/packages/preset-dumi/src/plugins/features/init.ts +++ b/packages/preset-dumi/src/plugins/features/init.ts @@ -33,4 +33,14 @@ export default (api: IApi) => { return memo; }); + + // re-enable @ & @@ umi default alias for integrated mode + if (isIntegrateUmi) { + api.modifyDefaultConfig((memo) => { + memo.alias['@'] = api.paths.absSrcPath; + memo.alias['@@'] = api.paths.absTmpPath; + + return memo; + }); + } }; diff --git a/packages/preset-dumi/src/routes/getRouteConfig.ts b/packages/preset-dumi/src/routes/getRouteConfig.ts index 7232a3cf1e..6d332bccc0 100644 --- a/packages/preset-dumi/src/routes/getRouteConfig.ts +++ b/packages/preset-dumi/src/routes/getRouteConfig.ts @@ -20,11 +20,11 @@ export default async (api: IApi, opts: IDumiOpts): Promise => { const exampleRoutePrefix = opts.mode === 'site' ? '/_' : '/_examples/'; const theme = await getTheme(); const userRoutes = opts.isIntegrate - ? await api.applyPlugins({ + ? (await api.applyPlugins({ key: 'dumi.getRootRoute', type: api.ApplyPluginsType.modify, initialValue: api.userConfig.routes, - }) + }))?.routes : api.userConfig.routes; if (userRoutes) {