tailwindcss/packages
Arsher. {Zach} f212b0fc22
fix: restore full page reload for watched external files on Vite 7.1+ (#19670)
# PR: Fix @source file changes not triggering full page reload on Vite
7.1+

## Description
This PR addresses issue #19637 where template files (PHP, HTML, Blade,
etc.) watched via the `@source` directive fail to trigger a full page
reload when using Vite 7.1 or newer.

## Root Cause
Vite 7.1 introduced the Environment API, which supersedes the legacy
WebSocket API for HMR. Specifically:
- `server.ws.send` is deprecated/ignored for certain external file
updates in favor of `server.hot.send`.
- The `@tailwindcss/vite` plugin currently collects `ViteDevServer`
instances but lacks a `handleHotUpdate` hook to explicitly trigger
reloads for non-module files added via `addWatchFile`.

## Changes
- Implemented a `handleHotUpdate` hook in the `@tailwindcss/vite`
plugin.
- The hook identifies changes to files that are not part of the standard
Vite module graph (e.g., `.php`, `.html`) but are watched by Tailwind.
- Triggers a `full-reload` using the new `server.hot.send` API if
available (Vite 7.1+), with a fallback to `server.ws.send` for backward
compatibility.

## Verification
- Reproduced the issue in a standalone Vite 7.1.0 project using a mock
plugin with the legacy API.
- Confirmed that the browser fails to reload upon editing a watched
`.php` file.
- Verified that migrating to `server.hot.send` restores the expected
reload behavior.

[ci-all]

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2026-02-17 20:04:17 +01:00
..
@tailwindcss-browser Fix Tailwind CSS package README GitHub links (#19644) 2026-02-07 19:26:38 -05:00
@tailwindcss-cli Fix Tailwind CSS package README GitHub links (#19644) 2026-02-07 19:26:38 -05:00
@tailwindcss-node Fix Tailwind CSS package README GitHub links (#19644) 2026-02-07 19:26:38 -05:00
@tailwindcss-postcss Fix Tailwind CSS package README GitHub links (#19644) 2026-02-07 19:26:38 -05:00
@tailwindcss-standalone Bump dependencies (#19608) 2026-02-04 12:38:50 +01:00
@tailwindcss-upgrade Fix Tailwind CSS package README GitHub links (#19644) 2026-02-07 19:26:38 -05:00
@tailwindcss-vite fix: restore full page reload for watched external files on Vite 7.1+ (#19670) 2026-02-17 20:04:17 +01:00
@tailwindcss-webpack Add @tailwindcss/webpack loader for Tailwind CSS v4 (#19610) 2026-01-29 14:16:31 +00:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Allow multiples of .25 in aspect-* fractions (#19688) 2026-02-17 19:32:31 +01:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00