8000 自定义Web构建模板,构建后会更改模板中特定字符 · Issue #18660 · cocos/cocos-engine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

自定义Web构建模板,构建后会更改模板中特定字符 #18660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tuyazuo opened this issue Apr 24, 2025 · 3 comments
Open

自定义Web构建模板,构建后会更改模板中特定字符 #18660

tuyazuo opened this issue Apr 24, 2025 · 3 comments
Labels
Bug Needs Triage Needs to be assigned by the team

Comments

@tuyazuo
Copy link
tuyazuo commented Apr 24, 2025

Cocos Creator version

3.8.6

System information

win11

Issue description

function base64ToUint8Array(base64String) {
      let padding = '='.repeat((4 - base64String.length % 4) % 4)
      let base64 = (base64String + padding)
        .replace(/-/g, '+')
        .replace(/_/g, '/')
      let rawData = atob(base64)
      let outputArray = new Uint8Array(rawData.length)
      for (let i = 0; i < rawData.length; i++) {
        outputArray[i] = rawData.charCodeAt(i)
      }
      return outputArray
    }

我的web构建模板index.ejs中有如上代码,开启md5构建后,生成的index.html文件,会将 .replace(/_/g, '/') 这行代码改为 .replace(/_/g, index.e0743.js'/'),即自动带上了 index脚本地址,导致语法错误。
经过排查发现构建后会把代码中包含 '/' 的地方都替换上index脚本地址,这个做法也是???

Relevant error log output

No response

Steps to reproduce

新建个web构建模板,加上上述代码

Minimal reproduction project

No response

@tuyazuo tuyazuo added Bug Needs Triage Needs to be assigned by the team labels Apr 24, 2025
@yanOO1497
Copy link
Contributor

没有复现你说的问题

Image

如果你用的是 html 构建模板是可能会,可以关闭这个实验室功能

Image

@tuyazuo
Copy link
Author
tuyazuo commented May 12, 2025
<script type="text/javascript">
    function base64ToUint8Array(base64String) {
      let padding = '='.repeat((4 - base64String.length % 4) % 4)
      let base64 = (base64String + padding)
        .replace(/-/g, '+')
        .replace(/_/g, '/')
      let rawData = atob(base64)
      let outputArray = new Uint8Array(rawData.length)
      for (let i = 0; i < rawData.length; i++) {
        outputArray[i] = rawData.charCodeAt(i)
      }
      return outputArray
    }
  </script>

代码放到script标签里啊

@tuyazuo
Copy link
Author
tuyazuo commented May 12, 2025

不仅是index.ejs里的会被更改,放在构建模板中的脚本文件 中的 / 字符也会被更改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

2 participants
0