fix: 使用环境变量动态设置页面标题
在index.html中使用%VITE_APP_TITLE%占位符替换硬编码的标题 修改vite.config.ts以在构建时将占位符替换为环境变量中的实际值
This commit is contained in:
@@ -111,7 +111,7 @@ export default ({ command, mode }) => {
|
||||
UNI_PLATFORM === 'h5' && {
|
||||
name: 'html-transform',
|
||||
transformIndexHtml(html) {
|
||||
return html.replace('%BUILD_TIME%', dayjs().format('YYYY-MM-DD HH:mm:ss'))
|
||||
return html.replace('%BUILD_TIME%', dayjs().format('YYYY-MM-DD HH:mm:ss')).replace('%VITE_APP_TITLE%', env.VITE_APP_TITLE)
|
||||
},
|
||||
},
|
||||
// 打包分析插件,h5 + 生产环境才弹出
|
||||
|
||||
Reference in New Issue
Block a user