nuxt-modules / nuxt-modules/tailwindcss

File paths passed to Tailwind CSS are not escaped

Open
#1,034 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
1.9k
Forks
192
PR merge metrics
No merged PRs in 30d

Description

Environment
  • @nuxtjs/tailwindcss: v6.14.0
  • tailwindcss: v3.4.18
  • nuxt: v3.13.0
Reproduction

No response

Describe the bug

It looks like @nuxtjs/tailwindcss collects page file paths and passes them to Tailwind CSS as content entries (which are treated as glob patterns).
Since these are actual file paths, they should be escaped so they are not interpreted as fast-glob patterns. However, they currently appear to be passed without escaping.

As a result, some files are excluded from Tailwind’s content scanning. For example, the following Nuxt dynamic route file is not scanned:

pages/[request-id]/index.vue

Because Tailwind’s content configuration is interpreted as fast-glob patterns, characters like [] are treated as pattern syntax rather than a literal file path.

Expected behavior

Files under Nuxt’s pages directory should be scanned by Tailwind even if the path contains characters with special meaning in glob patterns (e.g. []).

Actual behavior

Files under dynamic route directories (e.g. pages/[request-id]/...) are excluded from Tailwind’s scan, and utilities used only in those files are not generated.

Additional context
Proposed fix

For content entries that are concrete file paths (as opposed to intentionally provided glob patterns), escape them using fast-glob’s path escaping (e.g. escapePath(...)) before passing them to Tailwind. This ensures paths containing [] are treated as literal file paths.

Tailwind’s docs also mention that content entries are treated as glob patterns:
https://v3.tailwindcss.com/docs/content-configuration#configuring-source-paths

Notes
  • If the module passes other literal file paths (not patterns) to Tailwind besides pages, those may also need escaping.

  • With correct escaping, moduleOptions.experimental?.strictScanContentPaths might become unnecessary.

Logs

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the concrete path pages/[request-id]/index.vue enters Tailwind's content configuration, and compare it with intentionally provided glob patterns. Check the interaction with moduleOptions.experimental?.strictScanContentPaths. Done means utilities used in files with glob-special characters are generated by Tailwind's scan.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, tailwindcss, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.