百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
V

vite-plugin-html

> 编程语言
开源

一个用于处理 HTML 的 Vue.js 插件。它基于 lodash 模板开发。

685 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个用于处理 HTML 的 Vue.js 插件。它基于 lodash 模板开发。

vite-plugin-html

English | 中文

Features

  • HTML compression capability
  • EJS template capability
  • Multi-page application support
  • Support custom entry
  • Support custom template

Install (yarn or npm)

node version: >=12.0.0

vite version: >=2.0.0

bash
yarn add vite-plugin-html -D

或

bash
npm i vite-plugin-html -D

Usage

  • Add EJS tags to index.html, e.g.
xml

  
  
  
  
  
  • Configure in vite.config.ts, this method can introduce the required functions as needed
…

Multi-page application configuration

…

Parameter Description

createHtmlPlugin(options: UserOptions)

UserOptions

Parameter Types Default Description
entry string src/main.ts entry file path
template string index.html relative path to the template
inject InjectOptions - Data injected into HTML
minify boolean|MinifyOptions - whether to compress html
pages PageOption - Multi-page configuration

InjectOptions

Parameter Types Default Description
data Record - injected data
ejsOptions EJSOptions - ejs configuration OptionsEJSOptions
tags HtmlTagDescriptor - List of tags to inject

data can be accessed in html using the ejs template syntax

Env inject

By default, the contents of the .env file will be injected into index.html, similar to vite's loadEnv function

PageOption

Parameter Types Default Description
filename string - html file name
template string index.html relative path to the template
entry string src/main.ts entry file path
injectOptions InjectOptions - Data injected into HTML

MinifyOptions

Default compression configuration

typescript
    collapseWhitespace: true,
    keepClosingSlash: true,
    removeComments: true,
    removeRedundantAttributes: true,
    removeScriptTypeAttributes: true,
    removeStyleLinkTypeAttributes: true,
    useShortDoctype: true,
    minifyCSS: true,

Run the playground

bash
pnpm install

# spa
cd ./packages/playground/basic

pnpm run dev

# map
cd ./packages/playground/mpa

pnpm run dev

Example project

Vben Admin

License

MIT

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言