{"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,"search_vec":"'1.0.5':24 'activ':25 'address':45 'aim':43 'altern':35 'applic':21 'bug':46 'configur':56 'control':63 'differenti':51 'ej':13,52,77 'entry/template':55 'fix':29 'flexibl':54 'fork':33 'html':9,15,42,68,76 'htmlx':4 'inject':58 'javascript':64 'key':50 'maintain':26 'minif':16 'minifi':69 'mpa':66 'multi':19 'multi-pag':18 'page':20 'placement':62 'plugin':3,7,41,72,75 'precis':61 'process':10 'provid':12 'prs':49 'recent':28 'spa':65 'stall':38 'support':22 'tag':59 'templat':14,53 'typescript':78 'unmerg':48 'version':23 'vite':2,6,40,67,71,74 'vite-plugin':70 'vite-plugin-html':39,73 'vite-plugin-htmlx':1","created_at":"2026-04-27T17:06:32.953977+00:00","updated_at":"2026-04-27T17:06:32.953977+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/skymoonya/vite-plugin-htmlx","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-plugin-htmlx","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}