vite-plugin-sri3
v1.0.5
Published
Subresource Integrity in Vite
Downloads
13,792
Readme
vite-plugin-sri3
- 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.