gatsby-plugin-sri
Version:
Gatsby plugin for enabling Subresource Integrity (SRI)
75 lines (52 loc) • 2.66 kB
Markdown
# gatsby-plugin-sri
[](https://travis-ci.com/ovhemert/gatsby-plugin-sri)
[](https://www.codacy.com/app/ovhemert/gatsby-plugin-sri?utm_source=github.com&utm_medium=referral&utm_content=ovhemert/gatsby-plugin-sri&utm_campaign=Badge_Grade)
[](https://snyk.io/test/npm/gatsby-plugin-sri)
[](https://coveralls.io/github/ovhemert/gatsby-plugin-sri)
[](https://greenkeeper.io/)
[](http://standardjs.com/)
A Gatsby plugin to add Subresource Integrity (SRI) to your generated script tags.
```html
<script src="/webpack-runtime-cde5506958f1afc4d89e.js"></script>
```
becomes
```html
<script src="/webpack-runtime-cde5506958f1afc4d89e.js" integrity="sha512-uxm8lZAnmLGO3hMOyYy7HFgEGJgDdXwZR+Pdyt2f3AKbgVZ706v9YyI4t9veKTirqfdLGvPVDsDkHEWmWsECRA=="></script>
```
## Installation
With npm:
```bash
npm install --save gatsby-plugin-sri
```
Or with Yarn:
```bash
yarn add gatsby-plugin-sri
```
## Usage
In your `gatsby-config.js` file add:
```javascript
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-sri',
options: {
hash: 'sha512', // 'sha256', 'sha384' or 'sha512' ('sha512' = default)
crossorigin: false // Optional
}
}
]
}
```
The `crossorigin` option, if set to `true`, will optionally add add a `crossorigin="anonymous"` attribute to the script / style tags.
## 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](./docs/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 your generated tags, run: `gatsby build && gatsby serve`_