一个用于处理 HTML 的 Vue.js 插件。它基于 lodash 模板开发。
English | 中文
entrytemplatenode version: >=12.0.0
vite version: >=2.0.0
yarn add vite-plugin-html -D或
npm i vite-plugin-html -Dindex.html, e.g.
vite.config.ts, this method can introduce the required functions as needed…Multi-page application configuration
…createHtmlPlugin(options: 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 |
| 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
By default, the contents of the .env file will be injected into index.html, similar to vite's loadEnv function
| 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 |
Default compression configuration
collapseWhitespace: true,
keepClosingSlash: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
minifyCSS: true,pnpm install
# spa
cd ./packages/playground/basic
pnpm run dev
# map
cd ./packages/playground/mpa
pnpm run dev
MIT
暂无开放 Issues,或尚未同步最近议题。