From d42cb13e018cdd08cda7923549612cd7e8e30ff1 Mon Sep 17 00:00:00 2001 From: Kyrie Lin Date: Tue, 29 Oct 2024 01:04:09 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DsiteEffect=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4lib=E5=8C=85=E5=BC=95=E5=85=A5=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 - site/vite.config.js | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3f4c9bc01f..3848ad1471 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "CHANGELOG.md" ], "sideEffects": [ - "src/**/style/**", "dist/*", "site/*", "es/**/style/**", diff --git a/site/vite.config.js b/site/vite.config.js index 5998d40d37..4405a08808 100644 --- a/site/vite.config.js +++ b/site/vite.config.js @@ -13,6 +13,17 @@ const publicPathMap = { production: 'https://static.tdesign.tencent.com/react/', }; +const disableTreeShakingPlugin = (paths) => ({ + name: 'disable-treeshake', + transform(code, id) { + for (const path of paths) { + if (id.includes(path)) { + return { code, map: null, moduleSideEffects: 'no-treeshake' }; + } + } + }, +}); + export default ({ mode }) => defineConfig({ base: publicPathMap[mode], @@ -50,5 +61,5 @@ export default ({ mode }) => test: { environment: 'jsdom', }, - plugins: [react(), tdocPlugin(), VitePWA(pwaConfig)], + plugins: [react(), tdocPlugin(), VitePWA(pwaConfig), disableTreeShakingPlugin(['style/'])], });