Tailwind CSS base utilities not applied to production builds for TypeScript projects
See original GitHub issueBug report
Describe the bug
Production builds of Next.js do not apply the base Tailwind utilities in the static build if any components in the pages/
directory imports any external TypeScript components (such as components/nav.tsx
), the build only apply the styling added into the
To Reproduce
- Create a new NextJS project using
yarn create next-app project-name
- Select
with-tailwindcss
example project - Add required TypeScript dependencies
yarn add --dev typescript @types/react @types/node
- Rename
components/nav.js
tocomponents/nav.tsx
- Run
yarn run build && yarn run start
- Navigate to
http://localhost:3000
Expected behavior
That it would leverage the base Tailwind CSS utilities and appear as the default rather than the screen shot below.
Screenshots
The base utilities, such as flexbox, are lost. Only the styles using the @apply
attribute in styles/index.css
are applied.
System information
- OS: macOS
- Version of Next.js: 9.2.0
- Version of Node.js: 14.4.0
Additional context
This doesn’t seem to happen if any page components are using TypeScript, only if the components that the page components import are using TypeScript.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:19 (7 by maintainers)
Top Results From Across the Web
Angular tailwind utilities working fine in development, but not ...
When I build my Angular project I only sometimes get "No utility classes were detected in your source files." using tailwind, and sometimes ......
Read more >Configuration - Tailwind CSS
Generate a Tailwind config file for your project using the Tailwind CLI utility ... that can be used to generate extra utilities, components,...
Read more >Content Configuration - Tailwind CSS
This guide covers everything you need to know to make sure Tailwind generates all of the CSS needed for your project. . Configuring...
Read more >Adding Custom Styles - Tailwind CSS
Any custom styles you add to the base , components , or utilities layers will only be included in your compiled CSS if...
Read more >Using with Preprocessors - Tailwind CSS
Using PostCSS as your preprocessor. If you're using Tailwind for a brand new project and don't need to integrate it with any existing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey! Make sure you are configuring Tailwind to look through all the relevant files here:
https://github.com/vercel/next.js/blob/canary/examples/with-tailwindcss/tailwind.config.js#L2
The example you started with is only looking for
.js
files, so you just need to update that array of paths to also make sure it’s looking for any other file types that might contain any markup.Same for me