@jts-studios/vite-plugin-php
v1.1.1
Published
Vite plugin for PHP projects — hot reload, HTML minification, and PHP build integration.
Maintainers
Readme
@jts-studios/vite-plugin-php
Vite plugin for PHP projects — hot reload, HTML minification, and PHP build integration.
Install
npm install @jts-studios/vite-plugin-phpRequires
vite >= 5.0.0as a peer dependency.
Usage
// vite.config.js
import { PHP } from "@jts-studios/vite-plugin-php"
export default {
plugins: [
PHP({
entries: ["pages/index.php", "pages/about.php"],
verbose: false,
minifyHtml: true,
hotReload: true,
}),
],
}Options
| Option | Type | Default | Description |
|---|---|---|---|
| entries | string[] | required | PHP entry files to process |
| verbose | boolean | false | Enable detailed build logging |
| minifyHtml | boolean | true | Minify HTML output via html-minifier-terser |
| hotReload | boolean | true | Enable hot reload for PHP and CSS changes |
How It Works
The plugin operates in three phases:
- Dev server — proxies
/pages/requests to a local PHP server (port 3000) and injects the Vite HMR client into HTML responses - Hot update — triggers full-page reloads on
.phpchanges and CSS hot-swaps on stylesheet changes - Build — processes each PHP entry: minifies HTML, restores tokenised PHP blocks from
.jsonfragments, outputs final.phpfiles todist/
License
MIT
