MCPcopy
hub / github.com/vitejs/vite / runConfigHook

Function runConfigHook

packages/vite/src/node/config.ts:2690–2733  ·  view source on GitHub ↗
(
  config: InlineConfig,
  plugins: Plugin[],
  configEnv: ConfigEnv,
)

Source from the content-addressed store, hash-verified

2688}
2689
2690async function runConfigHook(
2691 config: InlineConfig,
2692 plugins: Plugin[],
2693 configEnv: ConfigEnv,
2694): Promise<InlineConfig> {
2695 let conf = config
2696
2697 const tempLogger = createLogger(config.logLevel, {
2698 allowClearScreen: config.clearScreen,
2699 customLogger: config.customLogger,
2700 })
2701 const context = new BasicMinimalPluginContext<
2702 Omit<PluginContextMeta, 'watchMode'>
2703 >(basePluginContextMeta, tempLogger)
2704
2705 for (const p of getSortedPluginsByHook('config', plugins)) {
2706 const hook = p.config
2707 const handler = getHookHandler(hook)
2708 const res = await handler.call(context, conf, configEnv)
2709 if (res && res !== conf) {
2710 if (hasBothRollupOptionsAndRolldownOptions(res)) {
2711 context.warn(
2712 `Both \`rollupOptions\` and \`rolldownOptions\` were specified by ${JSON.stringify(p.name)} plugin. ` +
2713 `\`rollupOptions\` specified by that plugin will be ignored.`,
2714 )
2715 }
2716 if (res.esbuild) {
2717 context.warn(
2718 `\`esbuild\` option was specified by ${JSON.stringify(p.name)} plugin. ` +
2719 `This option is deprecated, please use \`oxc\` instead.`,
2720 )
2721 }
2722 if (res.optimizeDeps?.esbuildOptions) {
2723 context.warn(
2724 `\`optimizeDeps.esbuildOptions\` option was specified by ${JSON.stringify(p.name)} plugin. ` +
2725 `This option is deprecated, please use \`optimizeDeps.rolldownOptions\` instead.`,
2726 )
2727 }
2728 conf = mergeConfig(conf, res)
2729 }
2730 }
2731
2732 return conf
2733}
2734
2735async function runConfigEnvironmentHook(
2736 environments: Record<string, EnvironmentOptions>,

Callers 2

resolveConfigFunction · 0.85
createWorkerPluginsFunction · 0.85

Calls 6

warnMethod · 0.95
createLoggerFunction · 0.90
getSortedPluginsByHookFunction · 0.90
getHookHandlerFunction · 0.90
mergeConfigFunction · 0.90

Tested by

no test coverage detected