构建生成的文件名称带有@等特殊符号,我们的cdn系统不支持这种文件,求问该怎么解决

构建之后有的文件的名称是带有特殊符号的,例如6f01cf7f-81bf-4a7e-bd5d-0afc19696480@b47c0@8fd34.png中的@符号,我们的cdn系统不支持这种非标准的文件上传,请问这种怎么解决

写个脚本或者插件,自动移除特殊字符

移除了引擎还能识别出来?

把压缩纹理勾上就可以了

简单方式解决(暂只适合json)
思路

  1. 写个工具(node/py)扫描构建出来的文件,把文件名里面的@替换成-,工具几行代码可以完成
  2. hook一下引擎的json下载逻辑
    如hook.js
function downloadFile(url, options, onProgress, onComplete) {
    var xhr = new XMLHttpRequest();
    var errInfo = "download failed: " + url + ", status: ";
    xhr.open('GET', url, true);

    if (options.xhrResponseType !== undefined) {
      xhr.responseType = options.xhrResponseType;
    }

    if (options.xhrWithCredentials !== undefined) {
      xhr.withCredentials = options.xhrWithCredentials;
    }

    if (options.xhrMimeType !== undefined && xhr.overrideMimeType) {
      xhr.overrideMimeType(options.xhrMimeType);
    }

    if (options.xhrTimeout !== undefined) {
      xhr.timeout = options.xhrTimeout;
    }

    if (options.xhrHeader) {
      for (var header in options.xhrHeader) {
        xhr.setRequestHeader(header, options.xhrHeader[header]);
      }
    }

    xhr.onload = function () {
      if (xhr.status === 200 || xhr.status === 0) {
        if (onComplete) {
          onComplete(null, xhr.response);
        }
      } else if (onComplete) {
        onComplete(new Error("" + errInfo + xhr.status + "(no response)"));
      }
    };

    if (onProgress) {
      xhr.onprogress = function (e) {
        if (e.lengthComputable) {
          onProgress(e.loaded, e.total);
        }
      };
    }

    xhr.onerror = function () {
      if (onComplete) {
        onComplete(new Error("" + errInfo + xhr.status + "(error)"));
      }
    };

    xhr.ontimeout = function () {
      if (onComplete) {
        onComplete(new Error("" + errInfo + xhr.status + "(time out)"));
      }
    };

    xhr.onabort = function () {
      if (onComplete) {
        onComplete(new Error("" + errInfo + xhr.status + "(abort)"));
      }
    };
    xhr.send(null);
    return xhr;
};
cc.assetManager.downloader.register('.json', function (url, options, callback) {
    options.xhrResponseType = 'json';
    let url_ = url.indexOf("@") > 0 ? url.replace(/@/g, "-") :url;
    downloadFile(url_, options, options.onFileProgress, callback);
});

  1. 在settings.xxx.json的jsList里面添加
    "jsList": ["hook.js"],