vite-plugin-sri4 3.0.0 → 4.0.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/README.md +12 -11
- package/dist/index.cjs +442 -177
- package/dist/index.js +442 -177
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ A Vite plugin to generate Subresource Integrity (SRI) hashes for your assets dur
|
|
|
27
27
|
- **Bypass Domains:** Option to specify domains to bypass SRI injection.
|
|
28
28
|
- **Missing Asset Handling:** Configurable warning suppression for missing assets.
|
|
29
29
|
- **Robust Content Support:** Handles various content types including strings, Buffer, and Uint8Array.
|
|
30
|
-
- **Vite Compatibility:** Compatible with Vite
|
|
30
|
+
- **Vite Compatibility:** Compatible with Vite 7.0 and Vite 8.0 (including the Rolldown-based native build path).
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
33
33
|
|
|
@@ -48,13 +48,13 @@ export default defineConfig({
|
|
|
48
48
|
plugins: [
|
|
49
49
|
sri({
|
|
50
50
|
// Optional. The security hash algorithm. Defaults to "sha384".
|
|
51
|
-
|
|
51
|
+
hashAlgorithm: 'sha384',
|
|
52
52
|
// Optional. Domains to bypass SRI injection.
|
|
53
53
|
bypassDomains: ['example.com'],
|
|
54
54
|
// Optional. Suppress warnings for missing assets.
|
|
55
55
|
ignoreMissingAsset: false,
|
|
56
|
-
// Optional.
|
|
57
|
-
|
|
56
|
+
// Optional. Log verbosity: 'silent' | 'error' | 'warn' | 'info' | 'debug'. Defaults to 'warn'.
|
|
57
|
+
logLevel: 'warn'
|
|
58
58
|
})
|
|
59
59
|
]
|
|
60
60
|
});
|
|
@@ -76,14 +76,14 @@ Output:
|
|
|
76
76
|
|
|
77
77
|
## Plugin Options
|
|
78
78
|
|
|
79
|
-
* `
|
|
80
|
-
The hash algorithm used for computing SRI. Default is sha384
|
|
79
|
+
* `hashAlgorithm` (string):
|
|
80
|
+
The hash algorithm used for computing SRI. Default is `sha384`. You may change it to other supported algorithms like `sha256` or `sha512`.
|
|
81
81
|
* `bypassDomains` (Array<string>):
|
|
82
82
|
Array of domain names where SRI injection should be skipped. This allows external resources from specified domains to be excluded from SRI checks (for example, when they may not support CORS).
|
|
83
83
|
* `ignoreMissingAsset` (boolean):
|
|
84
|
-
When true, suppresses warnings for assets that are not found in the bundle. Default is false
|
|
85
|
-
* `
|
|
86
|
-
|
|
84
|
+
When true, suppresses warnings for assets that are not found in the bundle. Default is `false`.
|
|
85
|
+
* `logLevel` (string):
|
|
86
|
+
Log verbosity. One of `silent`, `error`, `warn`, `info`, `debug`. Default is `warn`. Use `debug` to see per-resource decisions during the build.
|
|
87
87
|
|
|
88
88
|
## Example Project
|
|
89
89
|
|
|
@@ -150,11 +150,11 @@ The example project shows:
|
|
|
150
150
|
|
|
151
151
|
### Debug Mode
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
Set `logLevel: 'debug'` to see detailed logs:
|
|
154
154
|
|
|
155
155
|
```javascript
|
|
156
156
|
sri({
|
|
157
|
-
|
|
157
|
+
logLevel: 'debug'
|
|
158
158
|
})
|
|
159
159
|
```
|
|
160
160
|
|
|
@@ -163,6 +163,7 @@ This will show:
|
|
|
163
163
|
- SRI hash computation
|
|
164
164
|
- CORS checks
|
|
165
165
|
- Missing asset warnings
|
|
166
|
+
- Bundle-key fallback matches (when a URL is resolved via suffix match)
|
|
166
167
|
|
|
167
168
|
## Contributing
|
|
168
169
|
|