From e4734086733027beb772c03ceab52f1f4101f9d5 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Wed, 25 Sep 2019 01:33:47 +0100 Subject: [PATCH] feat: support native brotli --- lib/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/filter.js b/lib/filter.js index d62606d..f29de60 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -7,7 +7,7 @@ const Svgo = require('svgo') const zlib = require('zlib') const { promisify } = require('util') const gzip = promisify(zlib.gzip) -const br = require('iltorb') +const br = require('zlib').brotliCompress ? promisify(require('zlib').brotliCompress) : require('iltorb').compress const micromatch = require('micromatch') const isMatch = (path, patterns, options) => { @@ -194,7 +194,7 @@ function brotliFn () { const input = Buffer.from(assetTxt, 'utf-8') try { - const result = await br.compress(input) + const result = await br(input) if (options.logger) verbose.call(this, input, result.toString(), path, 'brotli') resolve(route.set(path + '.br', result)) } catch (err) {