Skip to content

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

Open
@tuyazuo

Description

@tuyazuo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageNeeds to be assigned by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions