Subresource integrity (SRI) plugin for Vite
npm install vite-plugin-subresource-integrityAdds subresource integrity hashes to script and stylesheet imports from your index.html file at build time.
1. npm i --save-dev vite-plugin-subresource-integrity
1. import subresourceIntegrity from "vite-plugin-subresource-integrity";
1. In your vite.config.js file:
``ts
import { defineConfig } from 'vite'
import subresourceIntegrity from 'vite-plugin-subresource-integrity'
export default defineConfig({
// …
plugins: [subresourceIntegrity()]
})
``
| 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) | |
Third Party JavaScript Management Cheat Sheet
Content Security Policy Cheat Sheet
Fork of @small-tech/vite-plugin-sri that uses typescript
How to execute a plugin after assets are fully generated?
How can I add Subresource Integrity(SRI) for Svelte/Svelte Kit after build
Found a bug, have a suggestion for a new feature? Submit an issue.