{"id":22560,"library":"vite-html-plugin","title":"vite-html-plugin","description":"A Vite plugin for processing HTML templates with EJS-like syntax, similar to html-webpack-plugin. Current stable version is 0.1.4 (last commit 2022). Provides a configureHtml() function to inject JS/CSS into HTML and supports EJS interpolation. Vite-native alternative to html-webpack-plugin with minimal configuration. Active development but limited documentation and test coverage.","status":"maintenance","version":"0.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/caoxiemeihao/vite-plugins","tags":["javascript","vite","plugin","html","ejs","template","webpack","typescript"],"install":[{"cmd":"npm install vite-html-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add vite-html-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-html-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin requires Vite as build tool","package":"vite","optional":false},{"reason":"used for template rendering","package":"ejs","optional":true}],"imports":[{"note":"ESM-only; does not support CommonJS require()","wrong":"const { configureHtml } = require('vite-html-plugin')","symbol":"configureHtml","correct":"import { configureHtml } from 'vite-html-plugin'"},{"note":"Default export is an object with configureHtml; named export preferred","wrong":"import { default as viteHtmlPlugin } from 'vite-html-plugin'","symbol":"default","correct":"import viteHtmlPlugin from 'vite-html-plugin'"},{"note":"Plugin type is from Vite, not this package","wrong":"import { Plugin } from 'vite-html-plugin'","symbol":"type Plugin","correct":"import { type Plugin } from 'vite'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { configureHtml } from 'vite-html-plugin';\n\nexport default defineConfig({\n  plugins: [\n    configureHtml({\n      entry: '/src/main.ts', // script entry\n      template: 'index.html', // HTML template\n      inject: {\n        data: { title: 'My App' },\n        ejs: true\n      }\n    })\n  ]\n});\n\n// index.html (template)\n<!DOCTYPE html>\n<html>\n<head>\n  <title><%= title %></title>\n</head>\n<body>\n  <div id=\"app\"></div>\n  <!-- script injected by plugin -->\n</body>\n</html>","lang":"typescript","description":"Shows basic usage: configureHtml plugin with EJS template, script entry injection, and custom data."},"warnings":[{"fix":"Pin version to 0.1.4: npm install vite-html-plugin@0.1.4","message":"v1.0.0 (backup) is unstable; use v0.1.4 for production","severity":"breaking","affected_versions":"=1.0.0"},{"fix":"No fix; use alternative plugin or full reload on template edits","message":"Plugin does not support HMR for HTML template changes; requires full reload","severity":"gotcha","affected_versions":"<=0.1.4"},{"fix":"Explicitly set inject: { ejs: true } in configureHtml() options","message":"options.inject.ejs is optional but defaults to false; set to true to enable EJS rendering","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add template: 'path/to/template.html' to configureHtml() options","cause":"Missing template option in configureHtml()","error":"Error: [vite-html-plugin] The 'template' option is required"},{"fix":"Provide inject object: inject: { data: {}, ejs: true }","cause":"Accessing options.inject without providing inject object","error":"TypeError: Cannot read properties of undefined (reading 'ejs')"},{"fix":"Install: npm install vite-html-plugin@0.1.4","cause":"Package not installed or using wrong import path","error":"Module not found: Error: Can't resolve 'vite-html-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}