A Vite plugin that adds Subresource Integrity (SRI) hashes to script and stylesheet imports in index.html at build time. Version 0.0.2 is current. Forked from @small-tech/vite-plugin-sri to fix an issue where dynamic imports were not handled correctly. Unlike the original, this plugin processes assets after Vite's build transformation, ensuring correct integrity hashes for dynamically imported modules. Released under ISC license.
npm install vite-plugin-sriVerified import paths — ran on the pinned version, not inferred.
Minimal Vite config to enable SRI hashing on all script and stylesheet imports.
Run `npx vite build` to generate SRI-enabled output.
Ensure this plugin is placed after any plugins that modify script/style paths.
Use same build artifacts for both hash computation and deployment.
Upgrade Vite to version 2.0.0 or later, or downgrade the plugin if possible.
Use `import sri from 'vite-plugin-sri'` (default import).
Rebuild the project to regenerate hashes based on current file content.