forked from @small-tech/vite-plugin-sri
@small-tech/vite-plugin-sri generates the integrity value in the transformIndexHtml hook, and if dynamic imports are used in the code, the correct integrity cannot be generated. This plugin is designed to solve this problem.
Subresource integrity (SRI) plugin for Vite.
Adds subresource integrity hashes to script and stylesheet imports from your index.html file at build time.
npm i --save-dev vite-plugin-sri
In your vite.config.js
file:
import { defineConfig } from 'vite'
import sri from 'vite-plugin-sri'
export default defineConfig({
// …
plugins: [sri()]
})
Then:
npx vite build
Run npm test
to test, npm run coverage
to run coverage.
Run npm run build
This will generate legacy CommonJS version of the module for compatibility with older Node projects.
If you’re looking for a generic Rollup plugin that does the same thing, see rollup-plugin-sri by Jonas Kruckenberg that this one was inspired by.
Small Technology Foundation is a tiny, independent not-for-profit.
We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.
Copyright © 2021-present Aral Balkan, Small Technology Foundation.
ISC.