Merge pull request #18 from curbengh/native-brotli

feat: support native brotli
This commit is contained in:
curbengh 2019-09-27 17:31:30 +09:30 committed by GitHub
commit c2e6b898a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {