Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
/ vite-plugin-sri Public archive

A Vite plugin that adds subresource integrity hashes to your index.html at build time.

License

Notifications You must be signed in to change notification settings

small-tech/vite-plugin-sri

Repository files navigation

@small-tech/vite-plugin-sri

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 @small-tech/vite-plugin-sri

Use

In your vite.config.js file:

import { defineConfig } from 'vite'
import sri from '@small-tech/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.

About

A Vite plugin that adds subresource integrity hashes to your index.html at build time.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published