Skip to content

JADSN1894/vite-plugin-sri

Repository files navigation

Svelte SRI plugin

In the future, this repository will be archived or maybe deleted and migrated to the following repository, which is accessible through the jsr.io package registry.

Adds subresource integrity hashes to script and stylesheet imports from your index.html file at build time.

npm version license MIT

Before

Before build

After

After build

Usage

  1. npm i --save-dev vite-plugin-subresource-integrity
  2. import subresourceIntegrity from "vite-plugin-subresource-integrity";
  3. In your vite.config.js file:
import { defineConfig } from 'vite'
import subresourceIntegrity from 'vite-plugin-subresource-integrity'

export default defineConfig({
  // …
  plugins: [subresourceIntegrity()]
})

Tested in

Framework Version
vanilla(v5.1.6) npm version
vue(v3.3.4) npm version
react(v18.2.0) npm version
preact(v10.16.0) npm version
lit(v2.8.0) npm version
svelte(v4.1.2) npm version
solid(v1.7.9) npm version
qwik(v1.2.6) npm version

Alternatives

rollup-plugin-sri

@small-tech/vite-plugin-sri

References

Rollup - Build Hooks

Third Party JavaScript Management Cheat Sheet

Content Security Policy Cheat Sheet

Ship ESM & CJS in one Package

Repositories

Fork of @small-tech/vite-plugin-sri that uses typescript

gatsby-plugin-sri

vite-plugin-inspect

DefinitelyTyped

GitHub issues

How to execute a plugin after assets are fully generated?

Discord

How can I add Subresource Integrity(SRI) for Svelte/Svelte Kit after build

Contributing

Found a bug, have a suggestion for a new feature? Submit an issue.

About

This plugin adds Subresource Integrity (SRI) attributes to all resources imported by your index.html file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published