question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tailwind CSS base utilities not applied to production builds for TypeScript projects

See original GitHub issue

Bug 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

  1. Create a new NextJS project using yarn create next-app project-name
  2. Select with-tailwindcss example project
  3. Add required TypeScript dependencies yarn add --dev typescript @types/react @types/node
  4. Rename components/nav.js to components/nav.tsx
  5. Run yarn run build && yarn run start
  6. 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. Screenshot_2020-06-26 Screenshot

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

96reactions
adamwathancommented, Jun 26, 2020

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.

1reaction
lucasozcommented, Jul 11, 2021

I’ve been trying to solve this complication for the past 2 hours. I’ve tried every method mentioned here. Still not working 😦 @adamwathan Screenshot 2021-07-07 at 9 18 12 PM

Same for me

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found