How to use the tinify.proxy function in tinify

To help you get started, we’ve selected a few tinify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skyujilong / tinypng-webpack-plugin / src / uploader.js View on Github external
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;

tinify

Node.js client for the Tinify API. Tinify compresses your images intelligently. Read more at https://tinify.com.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis