vite-plugin-sri
v0.0.2
Published
A Vite plugin that adds subresource integrity hashes to your index.html file at build time.
Downloads
8,981
Maintainers
Readme
vite-plugin-sri
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.
Install
npm i --save-dev vite-plugin-sri
Use
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
Test and coverage
Run npm test
to test, npm run coverage
to run coverage.
Build
Run npm run build
This will generate legacy CommonJS version of the module for compatibility with older Node projects.
See also
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.
Like this? Fund us!
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
Copyright © 2021-present Aral Balkan, Small Technology Foundation.
License
ISC.