Vite plugin (v4.0.0) that automatically generates Subresource Integrity (SRI) hashes for JavaScript and CSS assets during build, injecting integrity and crossorigin attributes into HTML. Supports configurable hash algorithms (sha256/sha384/sha512), domain bypassing, and custom log levels. Compatible with Vite 7 and 8 (including Rolldown). Active development, MIT license. Differentiators: CORS support check for external resources, robust content type handling (string/Buffer/Uint8Array), and debug logging. Alternative to rollup-plugin-sri with tighter Vite integration.
npm install vite-plugin-sri4No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic Vite configuration integrating vite-plugin-sri4 with SRI hash generation and domain bypass.
Upgrade Vite to >=7.0.0 or use vite-plugin-sri@2.x for older Vite versions.
Stick with 'sha384' unless a specific requirement exists.
Use require('vite-plugin-sri4').default or switch to import syntax.Add external domains to bypassDomains or ensure the server sends Access-Control-Allow-Origin.
Ensure your HTML is part of the Vite build (e.g., using index.html as entry point).
Change to `import sri from 'vite-plugin-sri4'`.
Run `npm install vite-plugin-sri4 --save-dev`.
Ensure plugin is invoked as `sri({...})` not just `sri`.Use `const sri = require('vite-plugin-sri4').default`.