Skip to content

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.

Terminal window
npm install -D pageflare

Add the plugin to your Vite config:

vite.config.ts
import pageflare from 'pageflare/vite'
export default defineConfig({
plugins: [pageflare()]
})

That’s it. Every vite build now runs pageflare on the output.

Pass options to customize behavior:

vite.config.ts
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
})
]
})
OptionTypeDefaultDescription
platformstring'auto'Deployment platform: auto, vercel, netlify, cloudflare-pages, none
logstring'warn'Log level: off, error, warn, info, debug
argsstring[][]Extra CLI flags passed to pageflare optimize

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/).

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:

vite.config.ts
// SvelteKit
import { sveltekit } from '@sveltejs/kit/vite'
import pageflare from 'pageflare/vite'
export default defineConfig({
plugins: [sveltekit(), pageflare()]
})
vite.config.ts
// Remix
import { vitePlugin as remix } from '@remix-run/dev'
import pageflare from 'pageflare/vite'
export default defineConfig({
plugins: [remix(), pageflare()]
})

pageflare replaces several Vite plugins. After adding pageflare/vite, you can remove:

Packagepageflare equivalent
vite-plugin-htmlHTML minification and injection
vite-plugin-imageminImage optimization and compression
vite-plugin-compress / vite-plugin-compressionAsset minification (HTML, CSS, JS, SVG)
vite-plugin-sitemapSitemap generation via llm.sitemap config

The plugin works with any deployment target. For platform-specific image optimization, set the platform option or see the platform guides:

Set the PAGEFLARE_LICENSE environment variable to unlock Pro optimizations (critical CSS, font subsetting, adaptive images, and more).

Terminal window
PAGEFLARE_LICENSE=your-key npm run build

Or add it to your .env file:

.env
PAGEFLARE_LICENSE=your-key

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.