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 styles not showing on generated site, after running nuxt generate

See original GitHub issue

Version

@nuxtjs/tailwindcss”: “^4.2.1”, “nuxt”: “^2.15.7”, “postcss”: “^8.3.5”

Reproduction Link

Repo: https://github.com/revueltai/nuxt-tailwind-poc

  1. Clone the repo
  2. Run yarn dev > The site should load with the correct styles
  3. Run yarn generate + yarn start > The site should generate correctly, but styles look broken when running it.

Steps to reproduce

Tailwind styles seem to not be included to the site, after running yarn generate. I am attaching an example repo that shows my problem in a context as close as possible to the real project I have to work on.

I see that if I set purging to false the generated site looks correct, but, as expected, the outputted css is very large.

I followed the installation steps stated here.

I tried many of the related answers on this repo’s issues, but none solved the problem 😦 .

At this stage I cannot figure it out if it is a dumb simple “you forgot to install something” problem, or some whitelisting I am missing, or if there is another issue going on.

Any help solving this will be greatly appreciated!

What is Expected?

The generated version should look the same as the dev one.

What is actually happening?

The generated version doesn’t show the styles for most of the elements.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

1reaction
stale[bot]commented, Jan 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

1reaction
nachoadjustcommented, Aug 13, 2021

In our case the problem lied on Tailwind purging those classes that were created as a result of a strings concatenation (in a computed prop for example).

This would work:

computed () {
    getFontSize () {
         return 'sm:text-xl' // the generated version would include the sm:text-xl class
    }
}

And this would fail:

data () {
  return {
     fontSize: 'text-xl'
  }
},
computed () {
    getFontSize () {
         return 'sm:' + this.fontSize  // the generated version would not include the sm:text-xl class
    }
}

Our temp solution, so far, has also been adding all those classes that were being purged into the safelist object.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tailwind styles not showing on generated site, after running ...
Steps to reproduce. Tailwind styles seem to not be included to the site, after running yarn generate . I am attaching an example...
Read more >
Dynamically created classes not available when using 'nuxt ...
The entire project works fine locally, but if I run nuxt build; nuxt start; it gets compiled without errors but none of the...
Read more >
Install Tailwind CSS with Nuxt.js
Using npm, install tailwindcss and its peer dependencies, as well as @nuxt/postcss8 , and then run the init command to generate the tailwind.config.js...
Read more >
How to set up and customize Tailwind in Nuxt.js - Mattermost
In this step, you'll learn to create custom components in Nuxt.js, style them using Tailwind CSS classes and import them into a Nuxt.js...
Read more >
Tailwind CSS | IntelliJ IDEA Documentation - JetBrains
Make sure the CSS and Tailwind CSS bundled plugins are enabled in the Installed tab of the Settings/Preferences | Plugins page as described...
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