这是我的异步加载器。它只是调用api然后添加响应源文件并返回。但它不起作用。任何人都可以帮助我吗?
const path = require('path');
const request = require('request');
function assetAdd(source){
var pathObj = path.parse(this.resourcePath);
var callback = this.async();
if (pathObj.base === 'index.js'){
request({url:'http://localhost:8282/mockAsset'}, function(err, response, body) {
source += body;
callback(null, source);
});
}else{
callback(null, source);
}
}
module.exports = assetAdd;