- 首先需要安装
vite-plugin-html
插件 - 在vite.config.ts文件中增加如下代码:
plugins: [
createHtmlPlugin({
minify: true,
pages: [
{
template: 'index.html',
filename: 'index.html',
injectOptions: {
data: {
title: 'vite-app',
buildTime: new Date().toLocaleString()
}
}
}
]
})
],
- index.html里面如何使用?
<meta name="build-time" content="<%- buildTime%>" />
<title><%- title%></title>
标签:index,ts,html,vue3,config,vite
From: https://www.cnblogs.com/wjs0509/p/17891258.html