Home / Function/ runConfigHook() — vite Function Reference

runConfigHook() — vite Function Reference

Architecture documentation for the runConfigHook() function in config.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  5db25367_d823_be14_869d_fc9affb91c51["runConfigHook()"]
  7da774f9_eca5_d54e_6e01_6bee7d460a2b["config.ts"]
  5db25367_d823_be14_869d_fc9affb91c51 -->|defined in| 7da774f9_eca5_d54e_6e01_6bee7d460a2b
  58c4a210_68fe_1b4d_ed49_d59203f97ef1["resolveConfig()"]
  58c4a210_68fe_1b4d_ed49_d59203f97ef1 -->|calls| 5db25367_d823_be14_869d_fc9affb91c51
  04e3b119_ae40_14a9_42ce_3951d83fc60d["createLogger()"]
  5db25367_d823_be14_869d_fc9affb91c51 -->|calls| 04e3b119_ae40_14a9_42ce_3951d83fc60d
  a188e507_b323_f6f4_af53_0ba33b92284c["getSortedPluginsByHook()"]
  5db25367_d823_be14_869d_fc9affb91c51 -->|calls| a188e507_b323_f6f4_af53_0ba33b92284c
  58719e23_70bd_67e0_1ed8_f61c19ec725b["getHookHandler()"]
  5db25367_d823_be14_869d_fc9affb91c51 -->|calls| 58719e23_70bd_67e0_1ed8_f61c19ec725b
  b5c7fa38_1ab6_baf0_5523_b633b5165ec2["hasBothRollupOptionsAndRolldownOptions()"]
  5db25367_d823_be14_869d_fc9affb91c51 -->|calls| b5c7fa38_1ab6_baf0_5523_b633b5165ec2
  657661b0_3b17_9113_8464_fda5dfafd706["mergeConfig()"]
  5db25367_d823_be14_869d_fc9affb91c51 -->|calls| 657661b0_3b17_9113_8464_fda5dfafd706
  3cf1d94a_16a2_96d6_7d1d_9757e22a2557["warn()"]
  5db25367_d823_be14_869d_fc9affb91c51 -->|calls| 3cf1d94a_16a2_96d6_7d1d_9757e22a2557
  style 5db25367_d823_be14_869d_fc9affb91c51 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/config.ts lines 2613–2656

async function runConfigHook(
  config: InlineConfig,
  plugins: Plugin[],
  configEnv: ConfigEnv,
): Promise<InlineConfig> {
  let conf = config

  const tempLogger = createLogger(config.logLevel, {
    allowClearScreen: config.clearScreen,
    customLogger: config.customLogger,
  })
  const context = new BasicMinimalPluginContext<
    Omit<PluginContextMeta, 'watchMode'>
  >(basePluginContextMeta, tempLogger)

  for (const p of getSortedPluginsByHook('config', plugins)) {
    const hook = p.config
    const handler = getHookHandler(hook)
    const res = await handler.call(context, conf, configEnv)
    if (res && res !== conf) {
      if (hasBothRollupOptionsAndRolldownOptions(res)) {
        context.warn(
          `Both \`rollupOptions\` and \`rolldownOptions\` were specified by ${JSON.stringify(p.name)} plugin. ` +
            `\`rollupOptions\` specified by that plugin will be ignored.`,
        )
      }
      if (res.esbuild) {
        context.warn(
          `\`esbuild\` option was specified by ${JSON.stringify(p.name)} plugin. ` +
            `This option is deprecated, please use \`oxc\` instead.`,
        )
      }
      if (res.optimizeDeps?.esbuildOptions) {
        context.warn(
          `\`optimizeDeps.esbuildOptions\` option was specified by ${JSON.stringify(p.name)} plugin. ` +
            `This option is deprecated, please use \`optimizeDeps.rolldownOptions\` instead.`,
        )
      }
      conf = mergeConfig(conf, res)
    }
  }

  return conf
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does runConfigHook() do?
runConfigHook() is a function in the vite codebase, defined in packages/vite/src/node/config.ts.
Where is runConfigHook() defined?
runConfigHook() is defined in packages/vite/src/node/config.ts at line 2613.
What does runConfigHook() call?
runConfigHook() calls 6 function(s): createLogger, getHookHandler, getSortedPluginsByHook, hasBothRollupOptionsAndRolldownOptions, mergeConfig, warn.
What calls runConfigHook()?
runConfigHook() is called by 1 function(s): resolveConfig.

Analyze Your Own Codebase

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

Try Supermodel Free