Skip to content

Regenerate Tailwind CSS when page content changes during watch #349

Open

Description

@bcomnes

Context

Follow-up to the review finding in PR #347, tracked separately at maintainer request. This is a watch/invalidation issue, separate from moving scaffold integration ownership into eject.

Reported behavior

With the Tailwind integration enabled, adding a previously unused utility class to an existing page.html or page.md during domstack watch rebuilds the HTML but does not regenerate the CSS for that utility. The class remains unstyled until the stylesheet changes or watch restarts.

Reported reproduction

Using a project configured with the Tailwind eject preset (domstack eject --css tailwind --yes, followed by dependency installation):

  1. Start domstack watch and let the initial build finish.
  2. Edit an existing src/page.html or src/page.md to add a Tailwind utility that was absent from the initial content scan, for example bg-fuchsia-700.
  3. Save without modifying any stylesheet.
  4. Observe that the page HTML updates but the corresponding utility is missing from the generated CSS.
  5. Touch the global stylesheet or restart watch; the utility then appears.

Expected: content-only edits that introduce Tailwind utilities update the generated CSS and served styling without requiring a stylesheet edit or watch restart.

Initial investigation

The esbuild-plugin-tailwindcss loader source cited by the review, for source declaring version 2.2.0, does not register scanned content as esbuild watch dependencies. Inspection of the installed plugin also shows its CSS loader returning processed contents without watchFiles or watchDirs. Consequently, Tailwind-scanned page content may be missing from the dependency information used to trigger CSS rebuilds.

Investigate whether the fix belongs in the plugin dependency registration, DOMStack watch invalidation, or a combination. Possible approaches include exposing the scanned dependencies to esbuild or explicitly invalidating/rebundling Tailwind CSS when relevant content changes.

The end-to-end watch behavior above is reported by the review; this follow-up did not independently reproduce it.

Acceptance criteria

  • Add watch regression coverage for introducing a previously unused utility through edits to existing HTML and Markdown pages.
  • Ensure the generated CSS updates without touching CSS or restarting watch.
  • Keep ordinary page-only watch behavior incremental; avoid unconditional CSS rebuilds for projects without a content-scanning CSS integration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions