5

I followed these steps from the Tailwind docs to add Tailwind CSS v3 to my Nuxt.js v2.15.8 project. Now, when I save a file while having npm run dev running, I get stuck in a rebuilding loop. It keeps building successfully, but then claiming that some random number was just updated so it rebuilds. I have to use Control + C to get it to exit.

↻ Updated components/Comment.vue                                                                                                                21:08:59

✔ Client
  Compiled successfully in 1.86s

✔ Server
  Compiled successfully in 1.49s

↻ Updated 1642194543006  

✔ Client
  Compiled successfully in 1.14s

✔ Server
  Compiled successfully in 1.62s 

↻ Updated 1642194545447

✔ Client
  Compiled successfully in 1.13s

✔ Server
  Compiled successfully in 947.08ms

↻ Updated 1642194547991

...

Does anyone know what might be causing this? The only 2 things I added to "nuxt.config.js" are below, directly out of the Tailwind CSS documentation.

// nuxt.config.js

buildModules: [
  // ...
  '@nuxt/postcss8',
],
// ...
build: {
  // ...
  postcss: {
    plugins: {
      tailwindcss: {},
      autoprefixer: {},
    },
  },
}
// tailwind.config.js

const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
  content: [
    './components/**/*.{js,vue,ts}',
    './layouts/**/*.vue',
    './pages/**/*.vue',
    './plugins/**/*.{js,ts}',
    './nuxt.config.{js,ts}',
  ],
  theme: {
    screens: {
      xxs: '360px',
      xs: '480px',
      ...defaultTheme.screens,
    },
    extend: {
      colors: {
        'blue-100': '#8ac7f9',
        'blue-150': '#72bbf7',
        'blue-200': '#5bb0f6',
        'blue-300': '#43a5f5',
        'blue-400': '#2c99f3',
        'blue-500': '#148ef2',
        'blue-600': '#1280da',
        'blue-700': '#1072c2',
        'blue-800': '#0e63a9',
        'blue-900': '#0c5591',
      },
    },
  },
  plugins: [],
}
6
  • What about tailwind config? Have you configured it? Commented Jan 14, 2022 at 21:29
  • @Danila Yes, it is configured. Added it to the bottom of the original question. Commented Jan 14, 2022 at 21:31
  • And you installed postcss@latest and autoprefixer@latest? latest might be the key, because Nuxt uses not latest versions by default. You can also try to move plugins or buildModules around, maybe it should be first or something Commented Jan 14, 2022 at 21:35
  • I tried playing around with removing everything, then just installing "@nuxt/postcss8" and I am still seeing the issue, so I don't think it is @latest related. Commented Jan 14, 2022 at 21:54
  • 2
    @Wonderman I didn't solve the issue, but but what I did find, is that Tailwind v3 is conflicting with the ESLint module in Nuxt. Are you using the ESLint module? If so, try disabling it and it should build correctly. For the time being, I am just using ESLint via VS Code. Don't need it as a built in build tool. Commented Jan 19, 2022 at 12:39

2 Answers 2

12

The problem is the following line:

module.exports = {
  content: [
    './nuxt.config.{js,ts}',
  ]
}

Change to (or simply keep only the one you are using):

module.exports = {
  content: [
    './nuxt.config.js',
    './nuxt.config.ts'
  ]
}

Source/Credits: https://github.com/nuxt-community/tailwindcss-module/issues/359#issuecomment-867956745

Sign up to request clarification or add additional context in comments.

2 Comments

You just saved my life! I had first attempts to update whole project with multiple dependecies last month, but literally gave up, bc i was not able to find the source of this evil endless build loop. Today another attempt, and by accident found out it was a tailwind issue. Your answer is first result on my google search. much love!
for me is not working :(
1

I've solve the problem with the following steps:

  1. Remove nuxt/tailwind module
  2. Follow the instructions for Tailwind 3 setup with Nuxt in the official documentation
  3. Check your buildModules in nuxt.config, remove '@nuxtjs/eslint-module' and add '@nuxt/postcss8'
  4. yarn clean
  5. yarn install

1 Comment

This works, but it would've been useful to explain and state what your findings were rather than just posting simple steps. It seems like there is a conflict between @nuxtjs/tailwind and @nuxtjs/eslint-module. As it was already stated in the comments, I don't think I need @nuxtjs/eslint-module, so I just removed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.