From 48e826f60e24661a2923bf7e7a3677224039b228 Mon Sep 17 00:00:00 2001 From: MyPrototypeWhat Date: Fri, 1 Aug 2025 17:17:16 +0800 Subject: [PATCH] chore: update Vite React SWC plugin and adjust Electron config for conditional styling - Upgraded `@vitejs/plugin-react-swc` from version 3.9.0 to 3.11.0 for improved performance and features. - Modified Electron Vite configuration to conditionally apply styled-components plugin based on the VITEST environment variable. - Updated snapshot tests for `InputEmbeddingDimension` and `Spinner` components to reflect style changes. --- electron.vite.config.ts | 24 ++++++++++--------- package.json | 2 +- .../InputEmbeddingDimension.test.tsx.snap | 4 ++-- .../__snapshots__/Spinner.test.tsx.snap | 1 + yarn.lock | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/electron.vite.config.ts b/electron.vite.config.ts index 0da977400a..a0ece37425 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -61,17 +61,19 @@ export default defineConfig({ (async () => (await import('@tailwindcss/vite')).default())(), react({ tsDecorators: true, - plugins: [ - [ - '@swc/plugin-styled-components', - { - displayName: true, // 开发环境下启用组件名称 - fileName: false, // 不在类名中包含文件名 - pure: true, // 优化性能 - ssr: false // 不需要服务端渲染 - } - ] - ] + plugins: process.env.VITEST + ? [] + : [ + [ + '@swc/plugin-styled-components', + { + displayName: true, // 开发环境下启用组件名称 + fileName: false, // 不在类名中包含文件名 + pure: true, // 优化性能 + ssr: false // 不需要服务端渲染 + } + ] + ] }), ...(isDev ? [CodeInspectorPlugin({ bundler: 'vite' })] : []), // 只在开发环境下启用 CodeInspectorPlugin ...visualizerPlugin('renderer') diff --git a/package.json b/package.json index a0a42f6c8e..f28bec5f5b 100644 --- a/package.json +++ b/package.json @@ -163,7 +163,7 @@ "@uiw/codemirror-extensions-langs": "^4.23.14", "@uiw/codemirror-themes-all": "^4.23.14", "@uiw/react-codemirror": "^4.23.14", - "@vitejs/plugin-react-swc": "^3.9.0", + "@vitejs/plugin-react-swc": "^3.11.0", "@vitest/browser": "^3.2.4", "@vitest/coverage-v8": "^3.2.4", "@vitest/ui": "^3.2.4", diff --git a/src/renderer/src/components/__tests__/__snapshots__/InputEmbeddingDimension.test.tsx.snap b/src/renderer/src/components/__tests__/__snapshots__/InputEmbeddingDimension.test.tsx.snap index b663328a98..f80954c2aa 100644 --- a/src/renderer/src/components/__tests__/__snapshots__/InputEmbeddingDimension.test.tsx.snap +++ b/src/renderer/src/components/__tests__/__snapshots__/InputEmbeddingDimension.test.tsx.snap @@ -7,7 +7,7 @@ exports[`InputEmbeddingDimension > basic rendering > should match snapshot with >
basic rendering > should match snapshot with >
should match snapshot 1`] = ` stroke-linecap="round" stroke-linejoin="round" stroke-width="2" + style="color: unset;" viewBox="0 0 24 24" width="16" xmlns="http://www.w3.org/2000/svg" diff --git a/yarn.lock b/yarn.lock index b6b02cd3b8..7199515ab4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7841,7 +7841,7 @@ __metadata: languageName: node linkType: hard -"@vitejs/plugin-react-swc@npm:^3.9.0": +"@vitejs/plugin-react-swc@npm:^3.11.0": version: 3.11.0 resolution: "@vitejs/plugin-react-swc@npm:3.11.0" dependencies: @@ -8201,7 +8201,7 @@ __metadata: "@uiw/codemirror-extensions-langs": "npm:^4.23.14" "@uiw/codemirror-themes-all": "npm:^4.23.14" "@uiw/react-codemirror": "npm:^4.23.14" - "@vitejs/plugin-react-swc": "npm:^3.9.0" + "@vitejs/plugin-react-swc": "npm:^3.11.0" "@vitest/browser": "npm:^3.2.4" "@vitest/coverage-v8": "npm:^3.2.4" "@vitest/ui": "npm:^3.2.4"