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.
Files changed (4) hide show
  1. package/README.md +12 -11
  2. package/dist/index.cjs +442 -177
  3. package/dist/index.js +442 -177
  4. 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 6.0 and 7.0.
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
- algorithm: 'sha384',
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. Enable debug logging.
57
- debug: false
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
- * `algorithm` (string):
80
- The hash algorithm used for computing SRI. Default is sha384. You may change it to other supported algorithms like sha256.
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
- * `debug` (boolean):
86
- When true, enables detailed debug logging. Default is false.
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
- Enable debug mode to see detailed logs:
153
+ Set `logLevel: 'debug'` to see detailed logs:
154
154
 
155
155
  ```javascript
156
156
  sri({
157
- debug: true
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