mirror of https://github.com/curbengh/hexo-yam
Merge pull request #18 from curbengh/native-brotli
feat: support native brotli
This commit is contained in:
commit
c2e6b898a9
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue