https://github.com/ovhemert/gatsby-plugin-brotli
Gatsby plugin for preparing brotli-compressed versions of assets
https://github.com/ovhemert/gatsby-plugin-brotli
brotli compress gatsby gatsby-plugin
Last synced: 15 days ago
JSON representation
Gatsby plugin for preparing brotli-compressed versions of assets
- Host: GitHub
- URL: https://github.com/ovhemert/gatsby-plugin-brotli
- Owner: ovhemert
- License: mit
- Created: 2018-08-20T19:49:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-30T14:35:42.000Z (over 1 year ago)
- Last Synced: 2025-05-27T20:04:58.172Z (about 1 month ago)
- Topics: brotli, compress, gatsby, gatsby-plugin
- Language: JavaScript
- Homepage:
- Size: 770 KB
- Stars: 27
- Watchers: 2
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
- Support: .github/SUPPORT.md
Awesome Lists containing this project
- awesome-list - gatsby-plugin-brotli - compressed versions of assets | ovhemert | 23 | (JavaScript)
README
# gatsby-plugin-brotli
[](https://github.com/ovhemert/gatsby-plugin-brotli/actions)
[](https://www.codacy.com/app/ovhemert/gatsby-plugin-brotli?utm_source=github.com&utm_medium=referral&utm_content=ovhemert/gatsby-plugin-brotli&utm_campaign=Badge_Grade)
[](https://snyk.io/test/npm/gatsby-plugin-brotli)
[](https://coveralls.io/github/ovhemert/gatsby-plugin-brotli)
[](http://standardjs.com/)Gatsby plugin for preparing brotli-compressed versions of assets.
```bash
/webpack-runtime-cde5506958f1afc4d89e.js
```
becomes
```bash
/webpack-runtime-cde5506958f1afc4d89e.js.br
```## Requirements
This plugin will only generate the compressed files. To see them been served to the client, your Gatsby website should run on a production server that supports Brotli .br-files. The Gatsby development server **does not** serve the compressed versions.
## Installation
With npm:
```bash
npm install --save gatsby-plugin-brotli
```Or with Yarn:
```bash
yarn add gatsby-plugin-brotli
```## Usage
In your `gatsby-config.js` file add:
```javascript
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-brotli'
}
]
}
```By default, only `.css` and `.js` files are compressed, but you can override this with the `extensions` option.
```javascript
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-brotli',
options: {
extensions: ['css', 'html', 'js', 'svg']
}
}
]
}
```By default, files are compressed using the highest level of compression supported by brotli, but you can override this with the `level` option.
```javascript
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-brotli',
options: {
level: 4
}
}
]
}
```You can even place all the brotli-compressed files (only the brotli ones, the uncompressed ones will
be saved in the `public` directory as usual) in a dedicated directory (ex. `public/brotli`):```javascript
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-brotli',
options: {
path: 'brotli'
}
}
]
}
```## Maintainers
Osmond van Hemert
[](https://github.com/ovhemert)
[](https://ovhemert.dev)## Contributing
If you would like to help out with some code, check the [details](./.github/CONTRIBUTING.md).
Not a coder, but still want to support? Have a look at the options available to [donate](https://ovhemert.dev/donate).
## Sponsors
[](https://www.browserstack.com/)
## License
Licensed under [MIT](./LICENSE).
_NOTE: This plugin only generates output when run in `production` mode! To test, run: `gatsby build && gatsby serve`_