我的应用程序的 javascript 位于与 index.html 不同的域
这让我在使用很棒的 ocLazyLoad 时遇到了问题。对延迟加载模块的请求是从 index.html 所在的域发出的。
例如:-
index.html = https://domain.com/index.html
app.bundle.js = https://different-domain.com/js/app.bundle.js
延迟加载包的请求变为 = https://domain.com/1.1.bundle.js
应该是:https://different-domain.com/js/1.1.bundle.js
路由解析:
resolve: {
load: function ($q, $ocLazyLoad) {
let deferred = $q.defer();
require.ensure([], function () {
let module = require('./path/to/module.js');
$ocLazyLoad.load({
name: 'moduleName'
});
deferred.resolve(module);
});
return deferred.promise;
}
}
有谁知道如何确保向正确的路径发出获取请求?
最佳答案
我在 webpack gitter 上问了这个问题,有人好心地指出了 output.publicPath
的方向,它解决了这个问题。
关于javascript - webpack 和 oclazyload - 为 require() 指定完整的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33938426/