-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Upgrade to Tailwind CSS v4 with CSS-first configuration #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Upgrade to Tailwind CSS v4 with CSS-first configuration #2
Conversation
- Remove packages/config package (no longer needed with Tailwind v4) - Convert JavaScript theme config to CSS @theme directive in globals.css - Update tsconfig.json to remove config package references - Simplify tailwind.config.ts to empty object (CSS-first approach) - Add React Router 7 routes.ts file for proper routing - Update documentation to reflect new CSS-first approach - Maintain full compatibility with shadcn/ui components - Support dark mode using @custom-variant and @variant directives This migration follows Tailwind v4's recommended CSS-first configuration approach, eliminating the need for JavaScript config files while maintaining all existing functionality.
|
Caution Review failedThe pull request is closed. WalkthroughThis change removes the Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant CSS (globals.css)
participant Tailwind v4 Engine
Developer->>CSS (globals.css): Define theme with @theme and @variant
Tailwind v4 Engine->>CSS (globals.css): Parse @theme and @variant directives
Tailwind v4 Engine-->>Developer: Generates utility classes based on CSS theme
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (12)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
README.md (1)
24-26: README inconsistencies: obsolete package entry and duplicated styling section
- Project structure (Line 24) still lists
config/, which is now gone.- Two separate “🎨 Styling” sections exist (Lines 98-108 and 128-136). The second is redundant after the new Tailwind section.
-│ ├── config/ # Shared configurations +│ ├── ui/ # shadcn/ui component library +│ └── utils/ # Shared utilities and typesand delete the second styling section entirely or merge any unique details into the first.
Also applies to: 80-83
🧹 Nitpick comments (4)
apps/todo-app/.react-router/types/app/routes/+types/home.ts (1)
1-2: Treat generated files as build artefacts, not source.This header explicitly marks the file as generated. Committing generated artefacts clutters the repo, inflates diffs, and risks merge conflicts. Prefer adding
.react-router/**(or at least*.react-router/types/**) to.gitignoreand regenerating in CI/postinstall.apps/todo-app/tailwind.config.ts (1)
1-5: Stub file may be unnecessary – consider deleting to avoid confusionTailwind v4 operates fine without any JS/TS config when using the CSS-first workflow. Keeping an empty
tailwind.config.tscan mislead newcomers into thinking configuration still belongs here.-// Tailwind CSS v4 uses CSS-first configuration -// Theme configuration is now in app/globals.css using @theme directive -// This file is no longer needed but kept for compatibility if needed - -export default {}; +// Intentionally left empty — Tailwind v4 is configured entirely via CSS. +// Delete this file if no build tools reference it.If no build tooling requires the file’s presence, removing it keeps the repo lean.
apps/todo-app/app/globals.css (2)
3-30: Consider addingcolor-schemeand browser-UI fallback tokensThe
@themeblock defines all visual tokens, but the browser itself (form controls, scrollbars, etc.) will still render using its default light palette unless a matchingcolor-schemeis declared. A single line keeps native UI in sync and makes the dark-variant override trivial:@theme { /* Colors - Light mode (default) */ @@ --radius-sm: calc(var(--radius) - 4px); + + /* Tell the browser we are in light mode so built-in widgets match */ + color-scheme: light; }Adding the matching
color-scheme: dark;inside the dark variant (see lines 35-56) will give you automatic dark scroll-bars and form controls without extra CSS.
35-56: Duplicate dark-mode tokens – inherit where possible to reduce maintenanceEvery colour token is re-declared in the dark variant even where the value is identical to light mode (e.g.
--color-ring). Omitting unchanged values lets the browser fall back to the light definition and keeps the dark palette DRY:@variant dark { - --color-ring: hsl(212.7 26.8% 83.9%); + /* Ring colour is identical to the light palette — omit to inherit */ } + +/* Also tell the browser we are now in dark mode */ +@variant dark { color-scheme: dark; }Less duplication means fewer places to update when branding changes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (15)
.cursorrules/monorepo.md(1 hunks)README.md(2 hunks)apps/todo-app/.react-router/types/+future.ts(1 hunks)apps/todo-app/.react-router/types/+routes.ts(1 hunks)apps/todo-app/.react-router/types/+server-build.d.ts(1 hunks)apps/todo-app/.react-router/types/app/+types/root.ts(1 hunks)apps/todo-app/.react-router/types/app/routes/+types/home.ts(1 hunks)apps/todo-app/app/globals.css(1 hunks)apps/todo-app/app/routes.ts(1 hunks)apps/todo-app/tailwind.config.ts(1 hunks)apps/todo-app/tsconfig.json(1 hunks)packages/config/package.json(0 hunks)packages/config/src/tailwind.config.ts(0 hunks)packages/config/src/tsconfig.json(0 hunks)tsconfig.json(1 hunks)
💤 Files with no reviewable changes (3)
- packages/config/src/tailwind.config.ts
- packages/config/src/tsconfig.json
- packages/config/package.json
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/todo-app/.react-router/types/app/routes/+types/home.ts (1)
apps/todo-app/.react-router/types/app/+types/root.ts (16)
LinkDescriptors(21-21)LinksFunction(22-22)MetaArgs(25-25)MetaDescriptors(26-26)MetaFunction(27-27)HeadersArgs(30-30)HeadersFunction(31-31)unstable_MiddlewareFunction(34-34)unstable_ClientMiddlewareFunction(37-37)LoaderArgs(40-40)ClientLoaderArgs(43-43)ActionArgs(46-46)ClientActionArgs(49-49)HydrateFallbackProps(52-52)ComponentProps(55-55)ErrorBoundaryProps(58-58)
apps/todo-app/.react-router/types/app/+types/root.ts (1)
apps/todo-app/.react-router/types/app/routes/+types/home.ts (16)
LinkDescriptors(24-24)LinksFunction(25-25)MetaArgs(28-28)MetaDescriptors(29-29)MetaFunction(30-30)HeadersArgs(33-33)HeadersFunction(34-34)unstable_MiddlewareFunction(37-37)unstable_ClientMiddlewareFunction(40-40)LoaderArgs(43-43)ClientLoaderArgs(46-46)ActionArgs(49-49)ClientActionArgs(52-52)HydrateFallbackProps(55-55)ComponentProps(58-58)ErrorBoundaryProps(61-61)
🔇 Additional comments (11)
apps/todo-app/.react-router/types/+future.ts (1)
1-9: LGTM! Standard React Router feature flag configuration.This is a well-structured type augmentation that properly extends React Router's Future interface. The
unstable_middleware: falseconfiguration correctly disables the unstable middleware feature using a literal boolean type.apps/todo-app/app/routes.ts (1)
1-5: LGTM! Clean route configuration using React Router 7 patterns.The route configuration correctly uses the
indexfunction to define the home route and applies proper type safety with thesatisfies RouteConfigassertion. This aligns well with React Router 7's file-based routing approach.apps/todo-app/.react-router/types/+server-build.d.ts (1)
3-17: LGTM! Comprehensive server build type declarations.The virtual module declaration properly re-exports all standard ServerBuild properties from React Router. The type mappings are correct and provide good type safety for server-side functionality including assets, routes, SSR configuration, and critical CSS extraction.
apps/todo-app/.react-router/types/+routes.ts (1)
5-27: LGTM! Proper route type mappings for single-page structure.The Register interface correctly defines the route structure with both
root.tsxandroutes/home.tsxmapping to the same "/" page. The type definitions properly establish the relationship between route files and their corresponding pages with appropriate IDs and parameter types.apps/todo-app/.react-router/types/app/+types/root.ts (2)
3-17: LGTM! Proper React Router internal type usage.The type definitions correctly use React Router's internal
GetInfoandGetAnnotationsutilities to derive route-specific types. The module reference to"../root.js"is appropriate for the compiled output structure.
19-59: LGTM! Comprehensive route type exports with consistent patterns.The Route namespace provides a complete set of type aliases covering all React Router functionality including links, meta, headers, middleware, loaders, actions, and component types. This pattern is consistent with the home route types and follows React Router's standard conventions.
apps/todo-app/.react-router/types/app/routes/+types/home.ts (2)
3-3: Avoid relying onreact-router/internal– it’s not a public API.Importing from
"react-router/internal"couples you to undocumented internals that may change without notice in minor/patch releases, breaking type-gen. Verify the codegen tool can instead reference the publicreact-routerentry points, or encapsulate this under your own re-export to soften future upgrades.
5-18: Verify the.jsextension targets actually exist at type-check time.All
import("../home.js")/import("../../root.js")references assume compiled JS siblings are present whentscruns. If you rely on TS-only sources (home.tsx,root.tsx) without emitting.jsbefore type-checking,tscwill raise TS2307 (“Cannot find module”).
Double-check the build order or extendtsconfig.json(allowJs,resolvePackageJsonExports, path mappings) so these imports always resolve.apps/todo-app/tsconfig.json (1)
2-3: Switch to relative base config looks good – double-check path mapping duplicationExtending
../../tsconfig.jsonis correct, but you now define additionalpathshere that are identical to those already present in the root config. This is harmless yet redundant; on large projects duplicated mappings become a maintenance hotspot.Consider deleting the
pathsblock unless you genuinely need app-specific overrides.tsconfig.json (1)
19-24: Removal of@todo-starter/configpaths LGTMThe updated mapping set is syntactically valid (no trailing comma issues) and reflects the package removal.
apps/todo-app/app/globals.css (1)
32-34: Verify@custom-variant darksyntax – the wrapped-parentheses form is non-standardTailwind v4 docs show:
@custom-variant dark ".dark &";Whereas the code uses:
@custom-variant dark (&:where(.dark, .dark *));The parentheses/
&:where()flavour is not in the examples and may fail to compile, depending on the exact Tailwind version. Please run a quick build to confirm it emits the expected.darkselector or switch to the canonical form.Would you run a dev build and confirm that the generated CSS contains rules prefixed with
.dark?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codegen-sh research if these react router types should be git ignored, then delete them commit and then add another commit with a change add to gitignore
|
@codegen-sh implement my code review comments
|
- Update .cursorrules/monorepo.md to remove 'config' from shared packages list - Remove generated React Router type files that should not be committed - Add .react-router/ to .gitignore as per React Router v7 documentation These generated type files are fully managed by React Router and should be gitignored according to the official documentation.
|
✅ Code review comments implemented successfully! I've addressed both issues from your code review: 🔧 Fixed Documentation Issue
🗂️ Fixed React Router Types Issue
✅ Verification
The changes have been committed and pushed to the existing PR branch. React Router will automatically regenerate the type files when you run the dev server, and they'll now be properly ignored by git as intended! 🚀 💻 View my work • 🛑 Stop |
|
@codegen-sh getting this error when trying to run dev todo-app:dev: Error: Route config file not found at "app/routes.ts".
|
|
🔍 Troubleshooting the Route Config Error The 🔄 Step 1: Pull Latest Changesgit fetch origin
git checkout codegen-bot/upgrade-to-tailwind-v4-proper-1754510773
git pull origin codegen-bot/upgrade-to-tailwind-v4-proper-1754510773🧹 Step 2: Clear Caches & Reinstall# Clear all caches
rm -rf node_modules
rm -rf apps/todo-app/node_modules
rm -rf .turbo
rm -rf apps/todo-app/.vite
rm -rf apps/todo-app/.react-router
# Reinstall dependencies
bun install✅ Step 3: Verify File Existsls -la apps/todo-app/app/routes.ts
cat apps/todo-app/app/routes.tsYou should see: import { type RouteConfig, index } from '@react-router/dev/routes';
export default [
index('routes/home.tsx')
] satisfies RouteConfig;🚀 Step 4: Try Dev Servercd apps/todo-app
bun dev🤔 If Still Not WorkingThe issue might be:
Let me know if you're still getting the error after these steps! 🛠️ 💻 View my work • 🛑 Stop |
- Delete .cursorrules/monorepo.md, .cursorrules/react-router-7.md, .cursorrules/README.md, and .cursorrules/ui-components.md as they are no longer relevant. - Clean up the codebase by removing unused cursor rules to streamline development and maintain consistency.
🎯 Overview
This PR upgrades the React Router 7 todo starter to properly use Tailwind CSS v4's CSS-first configuration approach, eliminating the need for JavaScript configuration files and simplifying the project structure.
✨ Key Changes
🗂️ Removed Config Package
packages/config- No longer needed with Tailwind v4's CSS-first approach🎨 CSS-First Theme Configuration
@themedirective - All theme configuration now lives in CSSapps/todo-app/app/globals.css@custom-variantand@variantdirectives🔧 Technical Improvements
🧪 Testing
bun devworksbun buildgenerates optimized CSS📚 Benefits of Tailwind v4 CSS-First
🔍 Migration Details
Before:
After:
This change represents a fundamental improvement in how we handle styling configuration, making the codebase more maintainable and aligned with modern Tailwind CSS best practices.
Requested by: User who wanted to initialize a React todo app boilerplate with best practices from the reportory repo
💻 View my work • About Codegen
⛔ Remove Codegen from PR • 🚫 Ban action checks
Summary by CodeRabbit
New Features
Documentation
Refactor
@themedirective in global styles.Chores