https://github.com/polyipseity/esbuild-compress
Plugin for esbuild that compresses embedded data, which will be decompressed at runtime, to reduce bundle size.
https://github.com/polyipseity/esbuild-compress
compress compression esbuild esbuild-plugin plugin
Last synced: over 1 year ago
JSON representation
Plugin for esbuild that compresses embedded data, which will be decompressed at runtime, to reduce bundle size.
- Host: GitHub
- URL: https://github.com/polyipseity/esbuild-compress
- Owner: polyipseity
- License: mit
- Created: 2023-05-14T13:29:17.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-11T12:48:24.000Z (over 1 year ago)
- Last Synced: 2025-02-14T07:50:54.597Z (over 1 year ago)
- Topics: compress, compression, esbuild, esbuild-plugin, plugin
- Language: JavaScript
- Homepage:
- Size: 375 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# esbuild-compress
[esbuild]: https://esbuild.github.io
Plugin for [esbuild] that compresses embedded data, which will be decompressed at runtime, to reduce bundle size.
## Usage
- Configuration:
```JavaScript
import { build } from "esbuild"
import esbuildCompress from "esbuild-compress"
import myBuildOptions from "./my-build-options.mjs"
await build({
...myBuildOptions,
plugins: [
esbuildCompress({
// see plugin options
compressors: [
{
filter: /\.json$/u,
loader: "json",
},
{
filter: /\.txt$/u,
lazy: true,
loader: "text",
},
],
}),
],
})
```
- Usage:
```JavaScript
import json from "./example.json"
import text0 from "./example.txt"
const text = await text0 // unnecessary if `lazy` is `false`
consumeJSON(json.key)
consumeText(text)
```