【issues/87】h5打包部署后,Oauth2认证后无法正确引入app.config.js文件

This commit is contained in:
JEECG
2025-05-27 17:30:26 +08:00
parent a48f9595f6
commit 0b48c6b655

View File

@@ -211,7 +211,16 @@ function createEnvConfigPlugin() {
const indexPath = path.join(outputDir, 'index.html')
if (fs.existsSync(indexPath)) {
let html = fs.readFileSync(indexPath, 'utf-8')
const scriptTag = '<script src="./app.config.js"></script>'
// update-begin-author:liaozhiyang date:2025-05-27 for:【issues/87】h5打包部署后,Oauth2认证后无法正确引入app.config.js文件
let prefix = '/'
if (env.VITE_APP_PUBLIC_BASE) {
prefix = env.VITE_APP_PUBLIC_BASE
}
if (prefix.endsWith('/')) {
prefix = prefix.slice(0, -1)
}
const scriptTag = `<script src="${prefix}/app.config.js"></script>`
// update-end-author:liaozhiyang date:2025-05-27 for:【issues/87】h5打包部署后,Oauth2认证后无法正确引入app.config.js文件
if (!html.includes('app.config.js')) {
html = html.replace('</title>', `</title> \n ${scriptTag}`)
fs.writeFileSync(indexPath, html, 'utf-8')