This page documents the frontend build infrastructure for Certimate, based on Vite and React. It covers how the application is compiled, how it integrates with the Go backend during development, and the specific optimizations used for production delivery.
Certimate uses Vite as its primary build tool and development server. The configuration is defined in ui/vite.config.ts and handles several critical tasks: version synchronization with the backend, path aliasing, and asset optimization.
To ensure the UI displays the correct version number and can perform update checks, the build toolchain extracts the AppVersion constant directly from the Go source code.
internal/app/app.go using fs.readFileSync ui/vite.config.ts14AppVersion string ui/vite.config.ts15serve (development mode), it appends a -dev suffix ui/vite.config.ts18-20define feature as __APP_VERSION__ ui/vite.config.ts32ui/src/domain/app.ts to export APP_VERSION ui/src/domain/app.ts1During development, the Vite server proxies API requests to the local PocketBase/Go backend to avoid Cross-Origin Resource Sharing (CORS) issues.
http://127.0.0.1:8090 ui/vite.config.ts67/api ui/vite.config.ts66The @ symbol is configured as an alias for the ./src directory to simplify imports across the project. This is reflected in the Vite config ui/vite.config.ts61-63
Sources:
The build process utilizes several plugins to manage styles, compatibility, and file persistence.
preserveFilesPluginThis plugin ensures that specific files in the dist directory are not deleted during the Vite build "emptyOutDir" phase.
dist/.gitkeep ui/vite.config.ts56-58ui/scripts/vite/plugins/preserve-files-plugin.ts ui/vite.config.ts9Certimate uses Tailwind CSS v4. The @tailwindcss/vite plugin is integrated into the Vite pipeline ui/vite.config.ts3 ui/vite.config.ts55
The CSS setup in ui/src/global.css handles the layer conflicts between Tailwind and Ant Design ui/src/global.css1-7 It defines custom variants and theme variables that bridge Tailwind's utility classes with Ant Design's design tokens ui/src/global.css13-43
legacyPlugin)Certimate targets modern browsers while providing polyfills for older environments.
renderLegacyChunks: false) to keep the bundle size optimized ui/vite.config.ts50-53To optimize loading, the i18n locale files are split into a separate manual chunk named locales.
manualChunks function in build.rolldownOptions.output checks if the module ID includes /src/i18n/ ui/vite.config.ts37-41Sources:
The following diagram illustrates how the version string travels from the Go backend source code into the compiled TypeScript environment.
Version Injection Flow
Sources:
Certimate includes a frontend service to check for new releases on GitHub or Gitee.
useVersionChecker HookThis hook manages the update detection logic ui/src/hooks/useVersionChecker.ts41
extractSemver ui/src/hooks/useVersionChecker.ts11-16compareVersions to determine if a fetched release is newer than the current APP_VERSION ui/src/hooks/useVersionChecker.ts18-33localStorage under certimate-ui-newver ui/src/hooks/useVersionChecker.ts35The version info is displayed in the UI via the AppVersion component. The ConsoleLayout uses isBrowserHappy() to check runtime compatibility ui/src/pages/ConsoleLayout.tsx27 If the browser is outdated, a warning alert is displayed ui/src/pages/ConsoleLayout.tsx59-61
Sources:
The build toolchain supports a highly configurable appearance system that synchronizes Tailwind CSS and Ant Design tokens.
The application calculates theme tokens based on the current themeMode (light/dark) ui/src/pages/settings/SettingsAppearance.tsx42-50 These tokens are matched with CSS variables defined in ui/src/global.css using the @theme and @layer base directives ui/src/global.css13-43
Users can modify appearance settings through the SettingsAppearance page ui/src/pages/settings/SettingsAppearance.tsx11-34
SettingsAppearanceTheme, allowing users to toggle between light and dark modes ui/src/pages/settings/SettingsAppearance.tsx37-74SettingsAppearanceLanguage, which triggers i18n.changeLanguage and updates the UI locale ui/src/pages/settings/SettingsAppearance.tsx77-106Entity Mapping: Appearance and Theming
Sources:
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.