当优化程序遇到作为网络路径的模块或脚本的路径时,会发生此错误。优化器只允许使用本地资源构建。要解决这个问题:
确保您将网络相关性作为模块名称而不是完整URL进行引用,以便在构建过程中将其映射到不同的网址:
//DO NOT DO THIS
require(['http://some.domain.dom/path/to/dependency.js'],
function (dependency) {});
//Rather, do this:
require.config({
paths: {
'dependency': 'http://some.domain.dom/path/to/dependency'
}
});
require(['dependency'], function (dependency) {});
如果要在构建/优化文件中包含此依赖关系,请下载JS文件,并在优化程序的构建概要文件中,放入指向该本地文件的paths配置。
如果要排除被列入该文件,只需要映射“依赖”,为构建(否则将无法建立),然后使用特殊的“空”的路径配置:
//Inside the build profile
{
paths: {
'dependency': 'empty:'
}
}