refactor: streamline styled-components plugin configuration in Electron Vite setup

- Consolidated the styled-components plugin configuration in the Electron Vite config file for improved readability and maintainability.
- Removed conditional application of the plugin based on the VITEST environment variable, ensuring consistent styling behavior across environments.
This commit is contained in:
MyPrototypeWhat 2025-08-01 18:10:51 +08:00
parent 876ce176de
commit 0302201f8a

View File

@ -61,19 +61,17 @@ export default defineConfig({
(async () => (await import('@tailwindcss/vite')).default())(), (async () => (await import('@tailwindcss/vite')).default())(),
react({ react({
tsDecorators: true, tsDecorators: true,
plugins: process.env.VITEST plugins: [
? [] [
: [ '@swc/plugin-styled-components',
[ {
'@swc/plugin-styled-components', displayName: true, // 开发环境下启用组件名称
{ fileName: false, // 不在类名中包含文件名
displayName: true, // 开发环境下启用组件名称 pure: true, // 优化性能
fileName: false, // 不在类名中包含文件名 ssr: false // 不需要服务端渲染
pure: true, // 优化性能 }
ssr: false // 不需要服务端渲染 ]
} ]
]
]
}), }),
...(isDev ? [CodeInspectorPlugin({ bundler: 'vite' })] : []), // 只在开发环境下启用 CodeInspectorPlugin ...(isDev ? [CodeInspectorPlugin({ bundler: 'vite' })] : []), // 只在开发环境下启用 CodeInspectorPlugin
...visualizerPlugin('renderer') ...visualizerPlugin('renderer')