Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (compilation, options) => {
//过滤文件尾缀名称
let reg = new RegExp("\.(" + options.ext.join('|') + ')$', 'i');
let keys = options.key;
if (options.proxy) {
//这里启用proxy 但是proxy因为建立scoket连接,最后需要有个超时的等待时间来关闭这个scoket
tinify.proxy = options.proxy;
}
return co(function* () {
//初始化字典
yield initDict;
let imgQueue = getImgQueue(compilation.assets, reg);
tinify.key = _.first(keys);
keys = _.drop(keys);
let result = yield Promise.all([
deImgQueue(imgQueue[0], keys),
deImgQueue(imgQueue[1], keys),
deImgQueue(imgQueue[2], keys)
]);
//将appendDict 保存到dict文件中
yield appendDictFile;
return result;