Registry / web-framework / vite-plugin-html-template-mpa

vite-plugin-html-template-mpa

JSON →
library1.0.33jsnpmunverified

Vite plugin for HTML template injection and multi-page application (MPA) support. Current stable version 1.0.33, with ongoing active development. Provides HTML minification, EJS template data injection, custom entry/template, and build output configuration including HTML hash, directory restructuring, and prefix replacement. Differentiates from alternatives like vite-plugin-html by actively supporting Vite 5 and offering built-in MPA features with a pages configuration system, while the older plugin is unmaintained. Ships TypeScript types.

npm install vite-plugin-html-template-mpa
INSTALL
IMPORT
SIG · VITE-PLUGIN-HTML-T
V
vite-plugin-html-template-mpa
web-frameworkjavascriptv1.0.33
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

htmlTemplate
import htmlTemplate from 'vite-plugin-html-template-mpa'
const htmlTemplate = require('vite-plugin-html-template-mpa')
ESM-only; plugin provides a default export.
Options
import type { Options } from 'vite-plugin-html-template-mpa'
import { Options } from 'vite-plugin-html-template-mpa'
Type-only import; Options is a TypeScript interface, not a runtime value.
PageOptions
import type { PageOptions } from 'vite-plugin-html-template-mpa'
Type-only import for the page configuration interface.

Configures Vite for MPA with custom pages, HTML minification, and build output restructuring.

import { defineConfig } from 'vite'; import htmlTemplate from 'vite-plugin-html-template-mpa'; // Multi-page application configuration export default defineConfig({ plugins: [ htmlTemplate({ pagesDir: 'src/views', pages: { 'index': { title: 'Home', entry: 'src/views/index/main.ts', template: 'public/index.html', }, 'about': { title: 'About Us', entry: 'src/views/about/main.ts', inject: { data: { title: 'About', }, tags: [ { injectTo: 'head', tag: 'meta', attrs: { name: 'description', content: 'About page' } } ], }, }, }, minify: true, buildCfg: { moveHtmlTop: true, htmlHash: true, }, }), ], });
Debug
Known issues
breakingAPI changes in version > 1.0.0: options and behavior differ from earlier versions.
fix
Refer to the updated documentation; the default `pagesDir` changed to `src/views`.
affects: >=1.0.0
gotchaMulti-page app directory default changed to `src/views`; if your pages are elsewhere, set `pagesDir` explicitly.
fix
Set `pagesDir` to your actual pages directory, e.g., `pagesDir: 'src/pages'`.
affects: >=1.0.0
gotchaPage configuration `urlParams` adds query parameters to the root navigation page only.
fix
Use `urlParams` for adding parameters to the generated index page links, not individual page templates.
affects: >=0.0.0
deprecatedPrevious plugin `vite-plugin-html` is unmaintained; this plugin intends to replace its functionality for SPA.
fix
Migrate from `vite-plugin-html` to this plugin for Vite 5 compatibility.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-html-template-mpa'
Plugin not installed or wrong import path.
fix
Run `pnpm add vite-plugin-html-template-mpa` and use default import as shown in quickstart.
TypeError: htmlTemplate is not a function
Using named import instead of default import.
fix
Use `import htmlTemplate from 'vite-plugin-html-template-mpa'`.
Vite build error: The 'pagesDir' option is required for multi-page mode.
Missing `pagesDir` configuration for MPA.
fix
Add `pagesDir` to the plugin options, e.g., `pagesDir: 'src/views'`.
Upgrade
Version history
1.0.33latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources