From fc03a02a83cd13d03162ee92491e351c47cecaaf Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Sun, 8 Oct 2023 15:19:19 +0800 Subject: [PATCH 1/2] fix: demo should export html file --- examples/normal/.dumirc.ts | 2 ++ src/features/compile/index.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/examples/normal/.dumirc.ts b/examples/normal/.dumirc.ts index b5a7c1c952..dfd12d7020 100644 --- a/examples/normal/.dumirc.ts +++ b/examples/normal/.dumirc.ts @@ -7,4 +7,6 @@ export default { mfsu: false, apiParser: {}, resolve: { entryFile: './src/index.ts' }, + ssr: {}, + exportStatic: {}, }; diff --git a/src/features/compile/index.ts b/src/features/compile/index.ts index 5af1c5fb6e..1c9ac7c52c 100644 --- a/src/features/compile/index.ts +++ b/src/features/compile/index.ts @@ -2,6 +2,7 @@ import type { IDemoLoaderOptions } from '@/loaders/demo'; import type { IMdLoaderOptions } from '@/loaders/markdown'; import ReactTechStack from '@/techStacks/react'; import type { IApi, IDumiTechStack } from '@/types'; +import { addAtomMeta, addExampleAssets } from '../assets'; export default (api: IApi) => { api.describe({ key: 'dumi:compile' }); @@ -109,6 +110,18 @@ export default (api: IApi) => { .options({ ...loaderBaseOpts, builtins: api.service.themeData.builtins, + onResolveDemos(demos) { + const assets = demos.reduce[0]>( + (ret, demo) => { + if ('asset' in demo) ret.push(demo.asset); + return ret; + }, + [], + ); + + addExampleAssets(assets); + }, + onResolveAtomMeta: addAtomMeta, } as IMdLoaderOptions); // get meta for each page component From 55dbe434698b65230a05b6d8ac0fca6d00959002 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Sun, 8 Oct 2023 15:20:39 +0800 Subject: [PATCH 2/2] chore: code clean --- examples/normal/.dumirc.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/normal/.dumirc.ts b/examples/normal/.dumirc.ts index dfd12d7020..b5a7c1c952 100644 --- a/examples/normal/.dumirc.ts +++ b/examples/normal/.dumirc.ts @@ -7,6 +7,4 @@ export default { mfsu: false, apiParser: {}, resolve: { entryFile: './src/index.ts' }, - ssr: {}, - exportStatic: {}, };