/esbuild-plugin-brotli

esbuild plugin brotli compress

Primary LanguageJavaScriptISC LicenseISC

esbuild-brotli-plugin for Node.js

npm version

An esbuild plugin to compress asset files with brotli.

How to use?

import tailwindCss from "./tailwind.css?br"

router.get('/assets/tailwind.css', () => {
    return new Response(tailwindCss, {
        headers: {
            "Content-Type": "text/css",
            "content-encoding": "br"
        }
    })
});

esbuild example

const esbuild = require('esbuild');
const brotliPlugin = require('esbuild-plugin-brotli');

esbuild.build({
    bundle: true,
    entryPoints: ['hello.js'],
    plugins: [brotliPlugin],
    write: false
}).then(result => {
    console.log(result.outputFiles[0].text);
}).catch(() => process.exit(1));