vite-plugin-sri3
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

vite-plugin-sri3

Subresource Integrity in Vite

  • Zero dependencies

Requirement

  • Vite >= 2
  • Nodejs >= 18

Install

# npm
npm i -D vite-plugin-sri3
# yarn
yarn add -D vite-plugin-sri3
# pnpm
pnpm i -D vite-plugin-sri3

Usage

// vite.config.(js|ts|mjs|mts)
import { defineConfig } from 'vite'
import sri from 'vite-plugin-sri3'

export default defineConfig({
  plugins: [
    // Please place it at the end to avoid ordering issues that might result in not getting the final content
    // Unless you are using a package like vite-plugin-compression2, in which case it should be placed before it.
    sri(),
  ],
})

Configuration

  • ignoreMissingAsset When using @vitejs/plugin-legacy, plugin can't not find some assets with legacy chunks. When this options enabled, plugin will ignore any missing asset error.

Default: false

sri({ ignoreMissingAsset: true })

Q&A

  • Why not rollup-plugin-sri or @small-tech/vite-plugin-sri ?
    • They can't work well in vite 4/5.

Thanks

Without the following plugins, this plugin wouldn't exist.

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-sri3

Weekly Downloads

846

Version

1.0.5

License

MIT

Unpacked Size

12.4 kB

Total Files

7

Last publish

Collaborators

  • yoyo930021