From 7d8a08e6a35430cb67062bd197eca57865a7982d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?chencheng=20=28=E4=BA=91=E8=B0=A6=29?= Date: Mon, 4 Nov 2024 11:12:45 +0800 Subject: [PATCH] fix: click-to-react-component should only be run in dev (#12764) --- .../src/features/clickToComponent/clickToComponent.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/preset-umi/src/features/clickToComponent/clickToComponent.ts b/packages/preset-umi/src/features/clickToComponent/clickToComponent.ts index f0c1f6adc7af..6a529df48e60 100644 --- a/packages/preset-umi/src/features/clickToComponent/clickToComponent.ts +++ b/packages/preset-umi/src/features/clickToComponent/clickToComponent.ts @@ -20,19 +20,21 @@ export default (api: IApi) => { enableBy: api.env === 'development' ? api.EnableBy.config : () => false, }); - const pkgPath = dirname(require.resolve('click-to-react-component')); api.modifyConfig((memo) => { + const pkgPath = dirname(require.resolve('click-to-react-component')); memo.alias['click-to-react-component'] = pkgPath; return memo; }); api.modifyAppData((memo) => { + const pkgPath = dirname(require.resolve('click-to-react-component')); memo.clickToComponent = { pkgPath, version: '1.0.8', }; return memo; }); + api.onGenerateFiles({ name: 'clickToComponent', fn: () => { @@ -61,6 +63,7 @@ return React.createElement( }); }, }); + api.addRuntimePlugin(() => [ winPath(join(api.paths.absTmpPath, 'plugin-clickToComponent/runtime.tsx')), ]);