Skip to content

yoyo930021/vite-plugin-sri3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

subresource integrity for vite

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published