feat: support native brotli

This commit is contained in:
curbengh 2019-09-25 01:33:47 +01:00
parent 60a045e429
commit e473408673
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
1 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ const Svgo = require('svgo')
const zlib = require('zlib') const zlib = require('zlib')
const { promisify } = require('util') const { promisify } = require('util')
const gzip = promisify(zlib.gzip) 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 micromatch = require('micromatch')
const isMatch = (path, patterns, options) => { const isMatch = (path, patterns, options) => {
@ -194,7 +194,7 @@ function brotliFn () {
const input = Buffer.from(assetTxt, 'utf-8') const input = Buffer.from(assetTxt, 'utf-8')
try { try {
const result = await br.compress(input) const result = await br(input)
if (options.logger) verbose.call(this, input, result.toString(), path, 'brotli') if (options.logger) verbose.call(this, input, result.toString(), path, 'brotli')
resolve(route.set(path + '.br', result)) resolve(route.set(path + '.br', result))
} catch (err) { } catch (err) {