Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intellisense won't work with a Nuxt3 project with a .tailwind.config.ts (typescript) file #591

Closed
lucavenir opened this issue Aug 8, 2022 · 8 comments

Comments

@lucavenir
Copy link

lucavenir commented Aug 8, 2022

What version of Tailwind CSS IntelliSense are you using?

v0.8.6

What version of Tailwind CSS are you using?

I'm using @nuxtjs/tailwindcss v5.3.1, which resolves to v3.1.8

What package manager are you using?

npm

What operating system are you using?

Ubuntu 22.04

Describe your issue

To reproduce, to the following:

  1. Start a new Nuxt3 project (docs)
  2. Install TailwindCSS on it (docs)
  3. Choose to use a tailwind.config.ts file (Typescript) like the following:
import { Config } from "tailwindcss";

export default <Config>{
  content: [
    "./components/**/*.{js,vue,ts}",
    "./layouts/**/*.vue",
    "./pages/**/*.vue",
    "./plugins/**/*.{js,ts}",
  ],
  theme: {},
  plugins: [],
};

TailwindCSS Intellisense outputs the following (extension outputs):

[Error - 6:52:46 PM] Tailwind CSS: No config file found.

Now, simply change the .ts file into a .js file, like so:

// tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./components/**/*.{js,vue,ts}",
    "./layouts/**/*.vue",
    "./pages/**/*.vue",
    "./plugins/**/*.{js,ts}",
  ],
  theme: {},
  plugins: [],
};

And tadah! This works. The extension outputs:

Found Tailwind CSS config file: /home/user/my-project-dir/tailwind.config.js
Loaded postcss v8.4.16: /home/user/my-project-dir/node_modules/postcss
Loaded tailwindcss v3.1.8: /home/user/my-project-dir/node_modules/tailwindcss

This simply means I'll just use a .js file as it changes nothing but this made me lose my mind for a couple of hours, so I'm opening this issue.

@lucavenir lucavenir changed the title Intellisense won't work on Nuxt3 with a .ts file Intellisense won't work with a Nuxt3 project with a .tailwind.config.ts (typescript) file Aug 8, 2022
@thecrypticace
Copy link
Contributor

This is because Tailwind CSS does not currently support TypeScript config files. We'd need to do a good bit of tooling work to support it. My guess is that Nuxt is compiling the tailwind.config.ts file and feeding the raw config to the postcss plugin (but not sure I'd have to look at the internals).

I gave a short explanation on why we don't (yet) support .ts files here: tailwindlabs/tailwindcss#7327 (comment)

@lucavenir
Copy link
Author

Sorry! I had no clue. I guess I got confused by their docs.

Have a nice day!

@P4sca1
Copy link

P4sca1 commented Oct 23, 2022

As of @nuxtjs/tailwindcss v6, it will generate a .nuxt/tailwind.config.cjs file, which contains your complete tailwind config. To use it, edit your .vscode/settings.json file and add "tailwindCSS.experimental.configFile": ".nuxt/tailwind.config.cjs".

@avxkim
Copy link

avxkim commented Dec 17, 2022

@P4sca1 had no effect for me. Using Nuxt 3.0.0 and latest @nuxtjs/tailwindcss

@P4sca1
Copy link

P4sca1 commented Dec 17, 2022

Have you started Nuxt one time so that the file gets generated?you might need to reload VSCode afterwards.

@avxkim
Copy link

avxkim commented Dec 17, 2022

@P4sca1 i've reloaded VSCode completely, then restarted nuxt with yarn dev, does it work for you? Might be missing some key detail probably

@P4sca1
Copy link

P4sca1 commented Dec 17, 2022

Yes, it works for me. You can check whether the tailwind.config.cjs file gets generated at the correct location.

@avxkim
Copy link

avxkim commented Dec 17, 2022

@P4sca1 yeah, it is located under this path: .nuxt/tailwind.config.cjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants