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.
This commit is contained in:
MyPrototypeWhat 2025-08-01 17:17:16 +08:00
parent b3aada01d8
commit 48e826f60e
5 changed files with 19 additions and 16 deletions

View File

@ -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')

View File

@ -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",

View File

@ -7,7 +7,7 @@ exports[`InputEmbeddingDimension > basic rendering > should match snapshot with
>
<div
class="ant-input-number css-dev-only-do-not-override-1261szd ant-input-number-outlined ant-input-number-compact-item ant-input-number-compact-first-item"
style="flex: 1;"
style="flex: 1 1 0%;"
>
<div
class="ant-input-number-handler-wrap"
@ -112,7 +112,7 @@ exports[`InputEmbeddingDimension > basic rendering > should match snapshot with
>
<div
class="ant-input-number css-dev-only-do-not-override-1261szd ant-input-number-outlined ant-input-number-compact-item ant-input-number-compact-first-item"
style="flex: 1;"
style="flex: 1 1 0%;"
>
<div
class="ant-input-number-handler-wrap"

View File

@ -26,6 +26,7 @@ exports[`Spinner > 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"

View File

@ -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"