- Zero dependencies
- Vite >= 2
- Nodejs >= 18
# npm
npm i -D vite-plugin-sri3
# yarn
yarn add -D vite-plugin-sri3
# pnpm
pnpm i -D vite-plugin-sri3
// 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(),
],
})
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 })
- Why not
rollup-plugin-sri
or@small-tech/vite-plugin-sri
?- They can't work well in vite 4/5.
Without the following plugins, this plugin wouldn't exist.