Vite plugin for inlining all JavaScript and CSS resources into a single HTML file. Version 2.3.3 is the latest stable release. The plugin is actively maintained with frequent updates. It differentiates from other inline plugins by focusing on producing a single index.html with no other output files, supporting Vite 5, 6, 7, and 8. It is specifically designed for offline web applications (single-file apps) and not recommended for server-hosted sites. The plugin automatically adjusts Vite build config for asset inlining and includes options to remove Vite's module loader and delete inlined files.
npm install vite-plugin-singlefileVerified import paths — ran on the pinned version, not inferred.
Basic configuration for a Vue.js app to inline all JS and CSS into a single HTML file.
Ensure your Vite config has only one input HTML file. Use vite-plugin-singlefile only for single-page applications.
Upgrade Node.js to version 18 or later.
Remove useRecommendedBuildConfig from options or set to true explicitly.
Disable sourcemaps in Vite config: build.sourcemap: false to avoid confusion.
Set deleteInlinedFiles: false if you want to keep the original files alongside the inline HTML.
Ensure only one entry HTML is specified, e.g., rollupOptions.input: 'index.html'.
Switch to import { viteSingleFile } from 'vite-plugin-singlefile' in an ESM context.Run npm install vite-plugin-singlefile and ensure vite and rollup meet version requirements.
Check the pattern syntax (glob) and verify the output file names. Use [] to inline all assets.