# 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> |
||
|---|---|---|
| .. | ||
| src | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsup.config.ts | ||
A utility-first CSS framework for rapidly building custom user interfaces.
Documentation
For full documentation, visit tailwindcss.com.
Community
For help, discussion about best practices, or feature ideas:
Discuss Tailwind CSS on GitHub
Contributing
If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.
@tailwindcss/vite plugin API
Enabling or disabling Lightning CSS
By default, this plugin detects whether or not the CSS is being built for production by checking the NODE_ENV environment variable. When building for production Lightning CSS will be enabled otherwise it is disabled.
If you want to always enable or disable Lightning CSS the optimize option may be used:
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
tailwindcss({
// Disable Lightning CSS optimization
optimize: false,
}),
],
})
It's also possible to keep Lightning CSS enabled but disable minification:
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
tailwindcss({
// Enable Lightning CSS but disable minification
optimize: { minify: false },
}),
],
})