vite-plugin-sri3 (v2.0.0) is a zero-dependency Vite plugin that automatically adds Subresource Integrity (SRI) hashes to script and link tags in your built HTML. It supports Vite 3 through 8, Node >=18, and ships TypeScript types. Unlike its predecessors (rollup-plugin-sri and @small-tech/vite-plugin-sri), this plugin works correctly with Vite 4/5+ and offers features like ignoreMissingAsset for legacy chunk compatibility and a skip-sri attribute to exclude specific tags. It is actively maintained with a changelog and comprehensive test coverage including unit tests, end-to-end Playwright tests for tamper detection, and integration fixtures ensuring deterministic sha384 hashes.
npm install vite-plugin-sri3Verified import paths — ran on the pinned version, not inferred.
Basic setup: import the named `sri` export, add it to your Vite plugins list, and build to get SRI hashes injected into HTML tags.
Reorder plugins: usually list sri() last. If using compression2, list sri() before it.
Enable sri({ ignoreMissingAsset: true }) when using @vitejs/plugin-legacy.Use import { sri } from 'vite-plugin-sri3' instead of require().Add skip-sri attribute to specific tags to exclude them from integrity injection.
Upgrade Vite >=3 and Node >=18.
Replace require('vite-plugin-sri3') with import { sri } from 'vite-plugin-sri3' in your vite.config.(js|ts|mjs|mts) file.Change import sri from 'vite-plugin-sri3' to import { sri } from 'vite-plugin-sri3'.Run npm i -D vite-plugin-sri3 and ensure Vite >=3 is installed.
Rebuild the project; if issue persists, verify no other plugins modify assets after sri() runs.