Skip to content

File paths passed to Tailwind CSS are not escaped #1034

@trrk

Description

@trrk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions