-
Notifications
You must be signed in to change notification settings - Fork 215
Tailwind CSS Intellisense does not work on Django project + django-tailwind #1312
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
Comments
Anyone??? |
@IgorArnaut seems like the last two releases of this extension aren't working well - see #1308, #1309 & #1320 Maybe try installing v0.14.13 as a workaround for now? |
@IgorArnaut I'm not seeing this in a freshly set up Django + Tailwind CSS v3 or v4 project in VSCode. I tested on both macOS and Windows: ![]() Could you provide the logs from the command "Tailwind CSS: Show Output" in the command palette? Also a reproduction project would probably be quite helpful here as well. |
Here: https://github.com/IgorArnaut/Django-TailwindCSS-Problem. Tailwind Intellisense DOES NOT WORK. |
Output:
|
So I can only reproduce this not working under the following scenario:
This happens because of a few things:
So what happens is IntelliSense thinks this is likely a v3 project, reads the content paths, think's they're relative to the project root, and then fails to match any file against those content paths. The fix for this, given that you're using v4 is to:
@import "tailwindcss";
/* Templates within theme app (e.g. base.html) */
@source "../../templates/**/*.html";
/* Templates in other apps */
@source "../../../**/templates/*.html";
/**
* A catch-all path to Django template files, JavaScript, and Python files
* that contain Tailwind CSS classes and will be scanned by Tailwind to generate the final CSS file.
*
* If your final CSS file is not being updated after code changes, you may want to broaden or narrow
* the scope of this path.
*/
@source "../../../**/*.{html,py,js}";
/* Ignore files in node_modules */
@source not "../../../**/node_modules"; I created a PR against your repo with those changes here: IgorArnaut/Django-TailwindCSS-Problem#1 |
The fix for this, given that you're using v4 is to:
Tailwind Intellisense still won't work. |
Can you provide the output from "Tailwind CSS: Show Output" please? Not just the "No matching project for document" but the entirety of it? It should start something similar to this:
|
Output:
|
Ah, okay! I think I know that the issue is. You're using a python virtual environment and it places the environment into the project directory so VSCode sees it as part of the workspace. But that folder is full of templates and stuff depending on which modules you have installed (for example Drop this into your user or workspace settings JSON in VSCode and that'll hopefully resolve the issue: "tailwindCSS.files.exclude": [
// IntelliSense default exclude settings
"**/.git/**", "**/node_modules/**", "**/.hg/**", "**/.svn/**",
// Also ignore my python virtual environment
"**/venv/**",
] We should probably add this to our default exclude settings |
IntelliSense, by default, ignores files for: - Version control (`.git`, `.hg`, `.svn`) - NPM (`node_modules`) I'm adding three more groups to this: - Python virtual environment folders (`.venv`, `venv`) - Yarn v2+ metadata & caches (`.yarn`) - *some* build caches (`.next`, `.turbo`, `.parcel-cache`, `__pycache__`) Discovered that we should update these when triaging #1312 (that one was specifically about python virtual envs)
What version of VS Code are you using?
v1.99.2
What version of Tailwind CSS IntelliSense are you using?
v0.14.15
What version of Tailwind CSS are you using?
v4.1.0
What package manager are you using?
npm
What operating system are you using?
Windows 11 64-bit
Tailwind config
VS Code settings
Describe your issue
I've installed django-tailwind to my existing Django project following instructions from https://django-tailwind.readthedocs.io/en/latest/installation.html. I've also installed junstyle's Django Template Support and your Tailwind CSS Intellisense extensions to VS Code.
Folder structure:
listings/templates/base.html:
Tailwind CSS Intellisense doesn't work in Django project. No suggested classes appear when typing in class attributes.
The text was updated successfully, but these errors were encountered: