vite-plugin-sri4 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +96 -6
- package/dist/index.cjs +540 -192
- package/dist/index.js +540 -192
- package/package.json +20 -15
- package/types/index.d.ts +60 -0
package/package.json
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-sri4",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "A Vite plugin to generate Subresource Integrity (SRI) hashes for output files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./types/index.d.ts",
|
|
10
11
|
"import": "./dist/index.js",
|
|
11
12
|
"require": "./dist/index.cjs"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
15
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"types",
|
|
18
|
+
"LICENSE"
|
|
16
19
|
],
|
|
17
20
|
"scripts": {
|
|
18
21
|
"build": "rollup -c",
|
|
19
22
|
"dev": "rollup -c -w",
|
|
23
|
+
"lint": "oxlint src test types example rollup.config.mjs vitest.config.js",
|
|
20
24
|
"test": "vitest run",
|
|
21
25
|
"test:watch": "vitest",
|
|
22
26
|
"test:coverage": "vitest run --coverage",
|
|
23
27
|
"prepublishOnly": "npm run build"
|
|
24
28
|
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"cross-fetch": "^4.1.0"
|
|
27
|
-
},
|
|
28
29
|
"peerDependencies": {
|
|
29
|
-
"vite": "^7.0.0 || ^8.0.0"
|
|
30
|
+
"vite": "^6.4.0 || ^7.0.0 || ^8.0.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@rollup/plugin-commonjs": "^
|
|
33
|
-
"@rollup/plugin-node-resolve": "^
|
|
34
|
-
"@vitest/coverage-v8": "^
|
|
35
|
-
"
|
|
36
|
-
"rollup": "^4.
|
|
37
|
-
"vite": "^8.
|
|
38
|
-
"vitest": "^
|
|
33
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
34
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
35
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
36
|
+
"oxlint": "^1.82.0",
|
|
37
|
+
"rollup": "^4.63.1",
|
|
38
|
+
"vite": "^8.2.2",
|
|
39
|
+
"vitest": "^5.0.0"
|
|
39
40
|
},
|
|
40
41
|
"keywords": [
|
|
41
42
|
"vite",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"subresource integrity"
|
|
45
46
|
],
|
|
46
47
|
"author": "Zac",
|
|
47
|
-
"license": "
|
|
48
|
+
"license": "MIT",
|
|
48
49
|
"publishConfig": {
|
|
49
50
|
"access": "public"
|
|
50
51
|
},
|
|
@@ -55,5 +56,9 @@
|
|
|
55
56
|
"bugs": {
|
|
56
57
|
"url": "https://github.com/7a6163/vite-plugin-sri4/issues"
|
|
57
58
|
},
|
|
58
|
-
"homepage": "https://github.com/7a6163/vite-plugin-sri4#readme"
|
|
59
|
+
"homepage": "https://github.com/7a6163/vite-plugin-sri4#readme",
|
|
60
|
+
"types": "./types/index.d.ts",
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18"
|
|
63
|
+
}
|
|
59
64
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Plugin } from 'vite'
|
|
2
|
+
|
|
3
|
+
/** The only algorithms the SRI spec defines; browsers reject anything else. */
|
|
4
|
+
export type SriHashAlgorithm = 'sha256' | 'sha384' | 'sha512'
|
|
5
|
+
|
|
6
|
+
export interface SriOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Hash algorithm used to compute the integrity value.
|
|
9
|
+
* @default 'sha384'
|
|
10
|
+
*/
|
|
11
|
+
hashAlgorithm?: SriHashAlgorithm
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Value for the injected `crossorigin` attribute. Tags that already declare
|
|
15
|
+
* one are left alone.
|
|
16
|
+
* @default 'anonymous'
|
|
17
|
+
*/
|
|
18
|
+
crossorigin?: 'anonymous' | 'use-credentials'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hostnames to leave untouched. Matches the host itself and its subdomains.
|
|
22
|
+
* Only applies to external (http/https) URLs; use the `skip-sri` attribute
|
|
23
|
+
* on a tag to opt a single element out.
|
|
24
|
+
* @default []
|
|
25
|
+
*/
|
|
26
|
+
bypassDomains?: string[]
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Warn instead of failing the build when an asset resolves to neither a
|
|
30
|
+
* bundle entry nor a file in `publicDir`.
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
ignoreMissingAsset?: boolean
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Log verbosity.
|
|
37
|
+
* @default 'warn'
|
|
38
|
+
*/
|
|
39
|
+
logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug'
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Inject `<script type="importmap">` carrying an `integrity` map for every
|
|
43
|
+
* JS chunk, covering modules loaded at runtime by `import()` that have no
|
|
44
|
+
* build-time tag to rewrite.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
importmap?: boolean
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Emit `sri-manifest.json` mapping every non-HTML output file to its hash,
|
|
51
|
+
* for servers that render HTML per request.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
manifest?: boolean
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare function sri(options?: SriOptions): Plugin
|
|
58
|
+
|
|
59
|
+
export default sri
|
|
60
|
+
export { sri }
|