Registry / web-framework / vite-plugin-singlefile

vite-plugin-singlefile

JSON →
library2.3.3jsnpmunverified

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-singlefile
INSTALL
IMPORT
SIG · VITE-PLUGIN-SINGLE
V
vite-plugin-singlefile
web-frameworkjavascriptv2.3.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

viteSingleFile
import { viteSingleFile } from 'vite-plugin-singlefile'
const viteSingleFile = require('vite-plugin-singlefile')
ESM-only package. Named export. CommonJS require will fail.
InlineConfig
import type { InlineConfig } from 'vite-plugin-singlefile'
import { InlineConfig } from 'vite-plugin-singlefile'
Type export only; not a runtime value. Use 'import type' or 'import { type InlineConfig }'.
default
import viteSingleFile from 'vite-plugin-singlefile'
const viteSingleFile = require('vite-plugin-singlefile').default
Default export is available but named export is preferred. CommonJS require is not supported.

Basic configuration for a Vue.js app to inline all JS and CSS into a single HTML file.

import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import { viteSingleFile } from 'vite-plugin-singlefile'; export default defineConfig({ plugins: [vue(), viteSingleFile({ useRecommendedBuildConfig: true, removeViteModuleLoader: false, inlinePattern: [], deleteInlinedFiles: true })], });
Debug
Known issues
gotchaMultiple entry points are not supported. The plugin only works with a single HTML entry point. See issue #51.
fix
Ensure your Vite config has only one input HTML file. Use vite-plugin-singlefile only for single-page applications.
affects: >=0.0.0
breakingv2.x requires Node.js >18.0.0. Node 16 is no longer supported.
fix
Upgrade Node.js to version 18 or later.
affects: >=2.0.0
deprecateduseRecommendedBuildConfig option is deprecated as of v2.3.0. The plugin now auto-applies recommended config.
fix
Remove useRecommendedBuildConfig from options or set to true explicitly.
affects: >=2.3.0
gotchaSourcemaps are not supported because inlining happens after sourcemap generation. They will be missing from the final output.
fix
Disable sourcemaps in Vite config: build.sourcemap: false to avoid confusion.
affects: >=0.0.0
gotchaThe plugin deletes inlined files by default (deleteInlinedFiles: true). This removes the original JS/CSS files from the output directory.
fix
Set deleteInlinedFiles: false if you want to keep the original files alongside the inline HTML.
affects: >=0.0.0
Errors
Common errors & fixes
Error: The plugin 'vite-plugin-singlefile' doesn't support multiple HTML files as entry points.
Vite configuration has multiple inputs (e.g., rollupOptions.input with more than one HTML file).
fix
Ensure only one entry HTML is specified, e.g., rollupOptions.input: 'index.html'.
TypeError: viteSingleFile is not a function
Using CommonJS require() on an ESM-only package.
fix
Switch to import { viteSingleFile } from 'vite-plugin-singlefile' in an ESM context.
[vite] RollupError: Could not resolve 'vite-plugin-singlefile' (required by ...)
Package is not installed or peer dependencies (vite, rollup) are missing or mismatched.
fix
Run npm install vite-plugin-singlefile and ensure vite and rollup meet version requirements.
Error: InlinePattern matched no assets. All assets will be inlined.
inlinePattern is set to a pattern that doesn't match any output files.
fix
Check the pattern syntax (glob) and verify the output file names. Use [] to inline all assets.
Upgrade
Version history
2.3.3latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required for Rollup integration
viterequiredpeer dependency; the plugin is a Vite plugin
Agent activity
49 hits · last 30 days
node
44
OpenAI (training)
1
Resources
vite-plugin-singlefile — npm install vite-plugin-singlefile · libregistry