{"id":20682,"library":"vite-plugin-singlefile","title":"vite-plugin-singlefile","description":"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.","status":"active","version":"2.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/richardtallent/vite-plugin-singlefile","tags":["javascript","vite","inline","css","SFA","single-file","typescript"],"install":[{"cmd":"npm install vite-plugin-singlefile","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-singlefile","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-singlefile","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for Rollup integration","package":"rollup","optional":false},{"reason":"peer dependency; the plugin is a Vite plugin","package":"vite","optional":false}],"imports":[{"note":"ESM-only package. Named export. CommonJS require will fail.","wrong":"const viteSingleFile = require('vite-plugin-singlefile')","symbol":"viteSingleFile","correct":"import { viteSingleFile } from 'vite-plugin-singlefile'"},{"note":"Type export only; not a runtime value. Use 'import type' or 'import { type InlineConfig }'.","wrong":"import { InlineConfig } from 'vite-plugin-singlefile'","symbol":"InlineConfig","correct":"import type { InlineConfig } from 'vite-plugin-singlefile'"},{"note":"Default export is available but named export is preferred. CommonJS require is not supported.","wrong":"const viteSingleFile = require('vite-plugin-singlefile').default","symbol":"default","correct":"import viteSingleFile from 'vite-plugin-singlefile'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport vue from '@vitejs/plugin-vue';\nimport { viteSingleFile } from 'vite-plugin-singlefile';\n\nexport default defineConfig({\n  plugins: [vue(), viteSingleFile({\n    useRecommendedBuildConfig: true,\n    removeViteModuleLoader: false,\n    inlinePattern: [],\n    deleteInlinedFiles: true\n  })],\n});","lang":"typescript","description":"Basic configuration for a Vue.js app to inline all JS and CSS into a single HTML file."},"warnings":[{"fix":"Ensure your Vite config has only one input HTML file. Use vite-plugin-singlefile only for single-page applications.","message":"Multiple entry points are not supported. The plugin only works with a single HTML entry point. See issue #51.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Node.js to version 18 or later.","message":"v2.x requires Node.js >18.0.0. Node 16 is no longer supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Remove useRecommendedBuildConfig from options or set to true explicitly.","message":"useRecommendedBuildConfig option is deprecated as of v2.3.0. The plugin now auto-applies recommended config.","severity":"deprecated","affected_versions":">=2.3.0"},{"fix":"Disable sourcemaps in Vite config: build.sourcemap: false to avoid confusion.","message":"Sourcemaps are not supported because inlining happens after sourcemap generation. They will be missing from the final output.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set deleteInlinedFiles: false if you want to keep the original files alongside the inline HTML.","message":"The plugin deletes inlined files by default (deleteInlinedFiles: true). This removes the original JS/CSS files from the output directory.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure only one entry HTML is specified, e.g., rollupOptions.input: 'index.html'.","cause":"Vite configuration has multiple inputs (e.g., rollupOptions.input with more than one HTML file).","error":"Error: The plugin 'vite-plugin-singlefile' doesn't support multiple HTML files as entry points."},{"fix":"Switch to import { viteSingleFile } from 'vite-plugin-singlefile' in an ESM context.","cause":"Using CommonJS require() on an ESM-only package.","error":"TypeError: viteSingleFile is not a function"},{"fix":"Run npm install vite-plugin-singlefile and ensure vite and rollup meet version requirements.","cause":"Package is not installed or peer dependencies (vite, rollup) are missing or mismatched.","error":"[vite] RollupError: Could not resolve 'vite-plugin-singlefile' (required by ...)"},{"fix":"Check the pattern syntax (glob) and verify the output file names. Use [] to inline all assets.","cause":"inlinePattern is set to a pattern that doesn't match any output files.","error":"Error: InlinePattern matched no assets. All assets will be inlined."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}