✅ Successfully demonstrates that @chotot/clad-ui components work with React (without Next.js) and Vite!
This project was created to test the compatibility of @chotot/clad-ui components with React and Vite, solving the Linaria v6 integration issues.
- React 18.3.1 - UI library
- Vite 6 - Build tool
- React Router 7 - Routing
- Linaria 6.2.0 - Zero-runtime CSS-in-JS (via @linaria/core and @linaria/react)
- WyW-in-JS - Build-time CSS extraction (@wyw-in-js/vite, @wyw-in-js/babel-preset)
- Clad UI 1.4.2 - Component library
- TypeScript 5.5.4 - Type safety
pnpm installpnpm devThen open http://localhost:5173
pnpm buildThe project uses @wyw-in-js/vite plugin (not @linaria/vite) because Linaria v6 is built on top of WyW-in-JS:
// vite.config.ts
import wyw from '@wyw-in-js/vite';
export default defineConfig({
plugins: [
wyw({
include: ['**/*.{ts,tsx}', '**/node_modules/@chotot/clad-ui/**/*.{js,jsx,ts,tsx}'],
babelOptions: {
presets: ['@wyw-in-js/babel-preset'],
},
}),
react(),
],
resolve: {
alias: {
'@@chotot/clad-ui/theme': path.resolve(__dirname, './src/theme/index.ts'),
},
},
optimizeDeps: {
esbuildOptions: {
loader: {
'.js': 'jsx', // Critical: Treat .js files from @chotot/clad-ui as JSX
},
},
},
});- WyW-in-JS Plugin: Linaria v6 requires
@wyw-in-js/vite, not@linaria/vite - Include Pattern: Must cover both app code and @chotot/clad-ui node_modules
- JSX Loader: @chotot/clad-ui's
.jsfiles contain JSX, so we needloader: { '.js': 'jsx' } - Theme Aliasing:
@@chotot/clad-ui/theme→./src/theme/index.ts - Dependencies: Add
lodashas @chotot/clad-ui uses it
The theme is imported from @chotot/clad-ui/theme/chotot and can be customized in src/theme/index.ts:
import theme from '@chotot/clad-ui/theme/chotot';
const appTheme = {
...theme,
// Override theme tokens here
};
export default appTheme;@chotot/clad-ui-vite-test/
├── src/
│ ├── theme/
│ │ └── index.ts # Clad UI theme configuration
│ ├── App.tsx # Main app with routing & @chotot/clad-ui components
│ └── main.tsx # Entry point
├── index.html
├── vite.config.ts # Vite + WyW-in-JS configuration
├── tsconfig.json # TypeScript configuration
└── package.json
- Linaria v6 compatibility: Used
@wyw-in-js/viteinstead of deprecated@linaria/vite - JSX in .js files: Configured esbuild loader to treat
.jsas JSX - Missing dependencies: Added
lodashwhich @chotot/clad-ui depends on - Theme resolution: Properly aliased
@@chotot/clad-ui/themepath
The warnings about Linaria peer dependencies can be ignored:
@chotot/clad-ui 1.4.2
├── ✕ unmet peer @linaria/core@^4.2.10: found 6.2.0
└── ✕ unmet peer @linaria/react@^4.3.8: found 6.2.0
@chotot/clad-ui works fine with Linaria v6 despite specifying v4 in peer dependencies.