{"id":22697,"library":"vite-plugin-htmlx","title":"vite-plugin-htmlx","description":"A Vite plugin for HTML processing that provides EJS templating, HTML minification, and multi-page application support. Version 1.0.5, actively maintained with recent fixes. It is a fork and alternative to the stalled vite-plugin-html, aiming to address bugs and unmerged PRs. Key differentiators: EJS templates, flexible entry/template configuration, and inject tags with precise placement control.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/skymoonya/vite-plugin-htmlx","tags":["javascript","spa","mpa","vite","html","minify","vite-plugin","vite-plugin-html","ejs","typescript"],"install":[{"cmd":"npm install vite-plugin-htmlx","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-htmlx","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-htmlx","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: requires Vite >=4.0.0","package":"vite","optional":false}],"imports":[{"note":"ESM-only; CommonJS require will fail","wrong":"const html = require('vite-plugin-htmlx')","symbol":"default (html)","correct":"import html from 'vite-plugin-htmlx'"},{"note":"Named export; also available as default export 'html'","wrong":"import createHtmlPlugin from 'vite-plugin-htmlx'","symbol":"createHtmlPlugin","correct":"import { createHtmlPlugin } from 'vite-plugin-htmlx'"},{"note":"Default export is the function; named export is 'createHtmlPlugin'","wrong":"import { html } from 'vite-plugin-htmlx'","symbol":"html (default)","correct":"import html from 'vite-plugin-htmlx'"},{"note":"UserOptions is exported as a type, not a value; use type-only import in TypeScript","wrong":"import { UserOptions } from 'vite-plugin-htmlx'","symbol":"UserOptions type","correct":"import type { UserOptions } from 'vite-plugin-htmlx'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport html from 'vite-plugin-htmlx';\n\nexport default defineConfig({\n  plugins: [\n    html({\n      minify: true,\n      page: {\n        entry: 'src/main.ts',\n        inject: {\n          data: {\n            title: 'My App',\n            injectScript: '<script src=\"./inject.js\"></script>',\n          },\n        },\n      },\n    }),\n  ],\n});","lang":"typescript","description":"Sets up vite-plugin-htmlx with HTML minification and EJS template data injection for a single-page app."},"warnings":[{"fix":"Upgrade Vite to 4.0.0 or later.","message":"Vite version requirement changed from >=3.0.0 to >=4.0.0 in v1.0.0","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use 'import html from 'vite-plugin-htmlx'' or 'import { createHtmlPlugin } from 'vite-plugin-htmlx''.","message":"Default export is named 'html', not 'createHtmlPlugin'. Confusing when migrating from vite-plugin-html.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For single page, use 'page: {...}'. For multi-page, use 'page: [{...}, ...]'.","message":"Multi-page config requires 'page' to be an array of MpaPage objects; single page uses an object.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use default import 'import html from 'vite-plugin-htmlx'' instead.","message":"The 'createHtmlPlugin' export is deprecated in favor of the default export 'html' since v1.0.0.","severity":"deprecated","affected_versions":"==1.0.0"},{"fix":"Always set explicit 'filename' for each MPA page entry.","message":"Filename defaults to 'index.html'. If you forget to set 'filename' for MPA pages, the last page with no filename may conflict.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure 'template' path in page config points to an existing HTML file, e.g., 'public/index.html'.","cause":"Specified template path is incorrect or file missing.","error":"Error: [plugin:vite-plugin-htmlx] The template file does not exist:"},{"fix":"Provide unique 'filename' for each MPA page entry, e.g., 'index.html', 'other.html'.","cause":"Multi-page build missing 'filename' config causing output file overwrite or missing.","error":"Error: [vite] RollupError: ENOENT: no such file or directory, open '.../dist/index.html'"},{"fix":"Set minify: true or provide valid MinifyOptions object.","cause":"Missing 'minify' option or invalid minify config.","error":"TypeError: Cannot read properties of undefined (reading 'replace')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}