Home / Function/ injectCspNonceMetaTagHook() — vite Function Reference

injectCspNonceMetaTagHook() — vite Function Reference

Architecture documentation for the injectCspNonceMetaTagHook() function in html.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  0819abd4_be39_9b71_5bc7_55025fbeb47e["injectCspNonceMetaTagHook()"]
  f8fe0737_718a_5509_b722_473f207d5906["html.ts"]
  0819abd4_be39_9b71_5bc7_55025fbeb47e -->|defined in| f8fe0737_718a_5509_b722_473f207d5906
  39f26be8_b1d9_a756_3043_474687a6bbb7["buildHtmlPlugin()"]
  39f26be8_b1d9_a756_3043_474687a6bbb7 -->|calls| 0819abd4_be39_9b71_5bc7_55025fbeb47e
  7a53712a_b13b_4bc2_85fc_b4de5cb705fb["createDevHtmlTransformFn()"]
  7a53712a_b13b_4bc2_85fc_b4de5cb705fb -->|calls| 0819abd4_be39_9b71_5bc7_55025fbeb47e
  style 0819abd4_be39_9b71_5bc7_55025fbeb47e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/html.ts lines 1188–1204

export function injectCspNonceMetaTagHook(
  config: ResolvedConfig,
): IndexHtmlTransformHook {
  return () => {
    if (!config.html?.cspNonce) return

    return [
      {
        tag: 'meta',
        injectTo: 'head',
        // use nonce attribute so that it's hidden
        // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce#accessing_nonces_and_nonce_hiding
        attrs: { property: 'csp-nonce', nonce: config.html.cspNonce },
      },
    ]
  }
}

Domain

Subdomains

Frequently Asked Questions

What does injectCspNonceMetaTagHook() do?
injectCspNonceMetaTagHook() is a function in the vite codebase, defined in packages/vite/src/node/plugins/html.ts.
Where is injectCspNonceMetaTagHook() defined?
injectCspNonceMetaTagHook() is defined in packages/vite/src/node/plugins/html.ts at line 1188.
What calls injectCspNonceMetaTagHook()?
injectCspNonceMetaTagHook() is called by 2 function(s): buildHtmlPlugin, createDevHtmlTransformFn.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free