Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer .gz and .br compression simultaneously #10

Closed
dilyanpalauzov opened this issue Mar 24, 2020 · 2 comments
Closed

Offer .gz and .br compression simultaneously #10

dilyanpalauzov opened this issue Mar 24, 2020 · 2 comments

Comments

@dilyanpalauzov
Copy link
Contributor

dilyanpalauzov commented Mar 24, 2020

I want to compress a file with gz and with brotli, so that browsers with brotli support get the .br file and the others get the .gz file.

Please provide an example with the shortest possible syntax that provides both brotli and .gz output from the same input.

@kryops
Copy link
Owner

kryops commented Mar 25, 2020

Interesting use case, I haven't thought of that before...

Have you tried adding the plugin twice to your build config? One instance to generate gz, and the other one for brotli. It might look something like this:

import { compress } from 'brotli'
import gzipPlugin from 'rollup-plugin-gzip'

const commonGzipPluginOptions = {
  // ...
}

// ...
    plugins: [
        gzipPlugin(commonGzipPluginOptions),
        gzipPlugin({
            ...commonGzipPluginOptions,
            customCompression: content => compress(Buffer.from(content)),
            fileName: '.br',
        }),
    ],

@dilyanpalauzov
Copy link
Contributor Author

Yes, that works. But I ask you to update the documentation and recommend this config.

@kryops kryops closed this as completed in bef3dc9 Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants