@its-thepoe/tailwindcss 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +45 -2
- package/package.json +1 -1
- package/reference.md +42 -0
package/SKILL.md
CHANGED
|
@@ -41,6 +41,49 @@ Example test:
|
|
|
41
41
|
<div class="m-4 rounded-md bg-blue-600 px-3 py-2 text-white">Tailwind OK</div>
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
## Next.js monorepos: the "Tailwind runs but generates no CSS" trap (v3 + sometimes v4)
|
|
45
|
+
|
|
46
|
+
Symptom pattern:
|
|
47
|
+
|
|
48
|
+
- Dev server runs, Tailwind appears "installed", but utilities do not apply.
|
|
49
|
+
- Tailwind warns it cannot find any classes / content, or the generated CSS is tiny.
|
|
50
|
+
|
|
51
|
+
Root cause (common in monorepos):
|
|
52
|
+
|
|
53
|
+
- Tailwind v3 only generates utilities for files it scans via `content` globs in `tailwind.config.*`.
|
|
54
|
+
- In a monorepo, Next can run with a different working directory than you think (especially when you run `next dev apps/web`, have multiple lockfiles, or the repo is ESM with `"type": "module"`).
|
|
55
|
+
- Relative paths inside `tailwind.config.*` and `postcss.config.*` then resolve from the wrong place, so Tailwind effectively scans nothing.
|
|
56
|
+
|
|
57
|
+
Hardening rules (do these when Tailwind scanning is flaky):
|
|
58
|
+
|
|
59
|
+
1. Run Next from the app directory (so all relative config paths line up):
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cd apps/web && next dev -p 3000
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2. Prefer `.cjs` for config files in ESM repos:
|
|
66
|
+
|
|
67
|
+
- If repo `package.json` has `"type": "module"`, then `postcss.config.js` / `tailwind.config.js` are treated as ESM and `module.exports` will crash.
|
|
68
|
+
- Use `postcss.config.cjs` / `tailwind.config.cjs` when you want CommonJS config.
|
|
69
|
+
|
|
70
|
+
3. If PostCSS is used, make it load the exact Tailwind config file explicitly (v3):
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
// postcss.config.cjs
|
|
74
|
+
module.exports = {
|
|
75
|
+
plugins: {
|
|
76
|
+
tailwindcss: { config: "./tailwind.config.cjs" },
|
|
77
|
+
autoprefixer: {},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Verification:
|
|
83
|
+
|
|
84
|
+
- Add the "Tailwind OK" test element to a real page and refresh.
|
|
85
|
+
- Re-run `next dev` from inside the app folder.
|
|
86
|
+
|
|
44
87
|
## Setup selection (pick one)
|
|
45
88
|
|
|
46
89
|
- Tailwind v4 + Vite plugin (`@tailwindcss/vite`) is the clean default for Vite apps.
|
|
@@ -92,7 +135,7 @@ CSS entry:
|
|
|
92
135
|
@tailwind utilities;
|
|
93
136
|
```
|
|
94
137
|
|
|
95
|
-
- `tailwind.config
|
|
138
|
+
- `tailwind.config.*` must exist and include correct `content` globs.
|
|
96
139
|
- PostCSS uses `tailwindcss` + `autoprefixer`.
|
|
97
140
|
|
|
98
141
|
Install (v3):
|
|
@@ -102,7 +145,7 @@ npm install -D tailwindcss postcss autoprefixer
|
|
|
102
145
|
npx tailwindcss init -p
|
|
103
146
|
```
|
|
104
147
|
|
|
105
|
-
`tailwind.config.
|
|
148
|
+
`tailwind.config.cjs` example (safe in ESM repos):
|
|
106
149
|
|
|
107
150
|
```js
|
|
108
151
|
module.exports = {
|
package/package.json
CHANGED
package/reference.md
CHANGED
|
@@ -10,6 +10,48 @@ Use this when setup is non-standard or the project is mid-migration.
|
|
|
10
10
|
- Identify build pipeline (Vite plugin vs PostCSS).
|
|
11
11
|
- Confirm content scanning covers files that contain class strings.
|
|
12
12
|
|
|
13
|
+
## Next.js monorepo + ESM pitfalls (high leverage)
|
|
14
|
+
|
|
15
|
+
If utilities don't apply but Tailwind "seems installed", assume **config resolution** is wrong until proven otherwise.
|
|
16
|
+
|
|
17
|
+
### 1) Working directory mismatch
|
|
18
|
+
|
|
19
|
+
In monorepos, `next dev` can effectively behave like it's running from a different root than you expect. If Tailwind config uses relative paths, content globs can silently stop matching.
|
|
20
|
+
|
|
21
|
+
Preferred fix:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cd apps/web && next dev
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If you have a repo-level `dev:web` script, make it `cd apps/web && next dev ...` rather than `next dev apps/web ...`.
|
|
28
|
+
|
|
29
|
+
### 2) ESM repo breaks `.js` CommonJS configs
|
|
30
|
+
|
|
31
|
+
If your repo root `package.json` includes `"type": "module"`:
|
|
32
|
+
|
|
33
|
+
- `postcss.config.js` and `tailwind.config.js` are treated as ESM.
|
|
34
|
+
- `module.exports = ...` will throw `ReferenceError: module is not defined`.
|
|
35
|
+
|
|
36
|
+
Fix: use `.cjs` for those configs when you want CommonJS:
|
|
37
|
+
|
|
38
|
+
- `postcss.config.cjs`
|
|
39
|
+
- `tailwind.config.cjs`
|
|
40
|
+
|
|
41
|
+
### 3) Pin Tailwind's config in PostCSS (v3)
|
|
42
|
+
|
|
43
|
+
When Tailwind v3 is running through PostCSS, explicitly point it at the right config so it can't "discover" the wrong one (or none):
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
// postcss.config.cjs
|
|
47
|
+
module.exports = {
|
|
48
|
+
plugins: {
|
|
49
|
+
tailwindcss: { config: "./tailwind.config.cjs" },
|
|
50
|
+
autoprefixer: {},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
13
55
|
## Setup recipes (minimal)
|
|
14
56
|
|
|
15
57
|
### V4 + Vite
|