Overview
When working with monorepos or shared component libraries, you may need to include source files from outside your main application directory. Uniwind leverages Tailwind CSS v4’s automatic content detection, which intelligently scans your project for class names without manual configuration.Not using a monorepo? This guide also applies to standard projects! If your
global.css is in a nested folder (like app/global.css for Expo Router) and you have components in other directories, you’ll need to use @source to include them.Tailwind v4 automatically excludes files listed in
.gitignore and binary file types, so you don’t need to worry about scanning node_modules or generated files.Including External Sources
If you’re using shared UI components from other packages in your monorepo, you can explicitly include them using the@source directive in your global.css file.
Using the @source Directive
Add the@source directive to your CSS entry file to include additional directories:
global.css
Common Use Cases
Expo Router with Components Outside App Directory
If you’re using Expo Router and yourglobal.css is in the app directory, but you have components in a separate components folder:
app/global.css
Shared Component Library
If your monorepo has a shared UI library that other apps consume:global.css
Multiple Package Sources
For complex monorepos with multiple component packages:global.css
Third-Party UI Libraries
Include custom UI libraries fromnode_modules that aren’t automatically detected:
global.css
How Automatic Detection Works
Tailwind v4 (and by extension, Uniwind) automatically discovers template files in your project using intelligent heuristics:- Respects .gitignore - Files in
.gitignoreare automatically excluded - Skips binary files - Images, videos, archives, and other binary formats are ignored
- Scans relevant files - Focuses on source files where className attributes are likely to appear
Important: The
cssEntryFile path in your metro.config.js determines the app root. Tailwind scans for classNames starting from the directory containing your global.css file. Files outside this directory require the @source directive.In most cases, you won’t need to configure anything. Automatic detection works out of the box for standard project structures.
When to Use @source
You typically only need the@source directive when:
- Your
global.cssis in a nested folder and you have components in sibling or parent directories (common with Expo Router) - Using shared components from other packages in a monorepo
- Consuming a custom UI library that’s outside your main app directory
- Working with Yarn/pnpm workspaces where packages are symlinked
- Including components from a private npm package that contains Uniwind classes
Troubleshooting
Classes Not Being Detected
If classes from your shared library or components aren’t being detected:- Check your
cssEntryFilepath inmetro.config.js- make sure it points to the correctglobal.csslocation - Verify the path in your
@sourcedirective is correct and relative to yourglobal.cssfile - Check that the files aren’t excluded by
.gitignore - Ensure the source directories contain actual source files, not just compiled JavaScript
- Restart your Metro bundler after adding
@sourcedirectives
Performance Concerns
If build times increase after adding@source:
- Make sure you’re not accidentally including large directories like
node_modules - Verify your
.gitignoreis properly configured to exclude build artifacts - Only include specific package directories rather than entire workspace roots