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 classes not imported to CSS without nuxt restart

See original GitHub issue

Environment

Nuxt CLI v3.0.0-rc.8
Nuxt project info:


  • Operating System: Linux
  • Node Version: v18.6.0
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: build, runtimeConfig
  • Runtime Modules: -
  • Build Modules: -

Reproduction

<template>
 <div class="">test</div>
</template>

then change it to

<template>
 <div class="p-5">test</div>
</template>

and save your file.

Describe the bug

Nuxt server will reload but the CSS for p-5 is not shown in the browser.

Additional context

No response

Logs

✔ Vite server built in 500ms

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
bfcommented, Aug 30, 2022

Okay, I was missing the “buildModules” option in my nuxt config.

New nuxt config which works:

import { defineNuxtConfig } from 'nuxt'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  build: {
    transpile: ['@heroicons/vue'],
    postcss: {
      postcssOptions: {
        plugins: {
          tailwindcss: {},
          autoprefixer: {},
        },
      },
    },
  },
  buildModules: ['@nuxtjs/tailwindcss'],
  runtimeConfig: {
    cookieName: '__session',
    cookieSecret:'foo'
  },
});

@Joaojack thanks for your kind help!

1reaction
Joaojackcommented, Aug 30, 2022

If i were you I would try to uninstall tailwindcss and install @nuxtjs/tailwindcss in devDependencies. Works flawlessly with Nuxt 3. https://tailwindcss.nuxtjs.org/ Config is good as it is (if you had a tailwind.config.js you can keep it too).

BTW i think you can keep everything in devDependencies now, that’s what i do since this discussion

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tailwind CSS classes is not working in my project?
This error is due to tailwind not finding any classes to scan in what it 'thinks' is your HTML code directories.
Read more >
Classes not being loaded in dev mode until Nuxt dev server is ...
Class doesn't appear, even after refreshing. Only after nuxt is restarted does the new class get added to the page. OR if 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 >
How to use Tailwind CSS with Nuxt.js | Kevin Regenrek
Table of Contents · 1. Quickstart TailwindCSS with the @nuxtjs/tailwindcss module. a) Start a new nuxt project; b) Add TailwindCSS to an 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