fix: 使用环境变量动态设置页面标题
在index.html中使用%VITE_APP_TITLE%占位符替换硬编码的标题 修改vite.config.ts以在构建时将占位符替换为环境变量中的实际值
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
'" />',
|
'" />',
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
<title>unibest</title>
|
<title>%VITE_APP_TITLE%</title>
|
||||||
<!--preload-links-->
|
<!--preload-links-->
|
||||||
<!--app-context-->
|
<!--app-context-->
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export default ({ command, mode }) => {
|
|||||||
UNI_PLATFORM === 'h5' && {
|
UNI_PLATFORM === 'h5' && {
|
||||||
name: 'html-transform',
|
name: 'html-transform',
|
||||||
transformIndexHtml(html) {
|
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 + 生产环境才弹出
|
// 打包分析插件,h5 + 生产环境才弹出
|
||||||
|
|||||||
Reference in New Issue
Block a user