vite-plugin-subresource-integrity
v0.0.12
Published
Subresource integrity (SRI) plugin for Vite
Downloads
19
Maintainers
Readme
Svelte SRI plugin
Adds subresource integrity hashes to script and stylesheet imports from your index.html
file at build time.
Before
After
Usage
npm i --save-dev vite-plugin-subresource-integrity
import subresourceIntegrity from "vite-plugin-subresource-integrity";
- In your
vite.config.js
file:
import { defineConfig } from 'vite'
import subresourceIntegrity from 'vite-plugin-subresource-integrity'
export default defineConfig({
// …
plugins: [subresourceIntegrity()]
})
Tested in
| Framework | Version | | ---------------- | -------------------------------------------------------------------------------------------------------------------- | | vanilla(v5.1.6) | | | vue(v3.3.4) | | | react(v18.2.0) | | | preact(v10.16.0) | | | lit(v2.8.0) | | | svelte(v4.1.2) | | | solid(v1.7.9) | | | qwik(v1.2.6) | |
Alternatives
References
Third Party JavaScript Management Cheat Sheet
Content Security Policy Cheat Sheet
Repositories
Fork of @small-tech/vite-plugin-sri that uses typescript
GitHub issues
How to execute a plugin after assets are fully generated?
Discord
How can I add Subresource Integrity(SRI) for Svelte/Svelte Kit after build
Contributing
Found a bug, have a suggestion for a new feature? Submit an issue.