Vite
Vite is the build tool behind many modern frameworks — SvelteKit, Remix, SolidStart, and plain Vite projects all use it. The pageflare/vite plugin hooks into Vite’s build pipeline and optimizes your output automatically after every build.
Install
Section titled “Install”npm install -D pageflareConfiguration
Section titled “Configuration”Add the plugin to your Vite config:
import pageflare from 'pageflare/vite'
export default defineConfig({ plugins: [pageflare()]})That’s it. Every vite build now runs pageflare on the output.
Options
Section titled “Options”Pass options to customize behavior:
import pageflare from 'pageflare/vite'
export default defineConfig({ plugins: [ pageflare({ platform: 'vercel', // deployment platform for image CDN log: 'info', // log level: off, error, warn, info, debug args: ['--force'], // extra CLI flags }) ]})| Option | Type | Default | Description |
|---|---|---|---|
platform | string | 'auto' | Deployment platform: auto, vercel, netlify, cloudflare-pages, none |
log | string | 'warn' | Log level: off, error, warn, info, debug |
args | string[] | [] | Extra CLI flags passed to pageflare optimize |
How It Works
Section titled “How It Works”The plugin uses Vite’s closeBundle hook, which fires after all output files have been written to disk. It then runs pageflare <outputDir> --in-place to optimize HTML, CSS, JS, images, and fonts in the build output.
The output directory is detected automatically from your Vite config (build.outDir, defaults to dist/).
SvelteKit, Remix, SolidStart
Section titled “SvelteKit, Remix, SolidStart”These frameworks use Vite as their build tool. The pageflare/vite plugin works with all of them — add it to your Vite config the same way:
// SvelteKitimport { sveltekit } from '@sveltejs/kit/vite'import pageflare from 'pageflare/vite'
export default defineConfig({ plugins: [sveltekit(), pageflare()]})// Remiximport { vitePlugin as remix } from '@remix-run/dev'import pageflare from 'pageflare/vite'
export default defineConfig({ plugins: [remix(), pageflare()]})Replacing plugins
Section titled “Replacing plugins”pageflare replaces several Vite plugins. After adding pageflare/vite, you can remove:
| Package | pageflare equivalent |
|---|---|
vite-plugin-html | HTML minification and injection |
vite-plugin-imagemin | Image optimization and compression |
vite-plugin-compress / vite-plugin-compression | Asset minification (HTML, CSS, JS, SVG) |
vite-plugin-sitemap | Sitemap generation via llm.sitemap config |
Deploying
Section titled “Deploying”The plugin works with any deployment target. For platform-specific image optimization, set the platform option or see the platform guides:
- Vercel — automatic Vercel Image Optimization
- Netlify — automatic Netlify Image CDN
- Cloudflare Pages — Cloudflare Image Resizing
Pro License
Section titled “Pro License”Set the PAGEFLARE_LICENSE environment variable to unlock Pro optimizations (critical CSS, font subsetting, adaptive images, and more).
PAGEFLARE_LICENSE=your-key npm run buildOr add it to your .env file:
PAGEFLARE_LICENSE=your-keyTroubleshooting
Section titled “Troubleshooting”Plugin doesn’t run
Make sure you’re running vite build, not vite dev. The plugin only runs during production builds (apply: 'build').
pageflare processes 0 files
The output directory may be empty when pageflare runs. Check that other plugins aren’t deleting or moving files after the build. Run with log: 'debug' to see which directory pageflare is scanning.
Conflicts with other post-build plugins
If another Vite plugin also uses closeBundle, ordering matters. Place the pageflare plugin last in the plugins array so it runs after all other plugins have finished writing files.