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

Function runConfigEnvironmentHook

packages/vite/src/node/config.ts:2735–2760  ·  view source on GitHub ↗
(
  environments: Record<string, EnvironmentOptions>,
  plugins: Plugin[],
  logger: Logger,
  configEnv: ConfigEnv,
  isSsrTargetWebworkerSet: boolean,
)

Source from the content-addressed store, hash-verified

2733}
2734
2735async function runConfigEnvironmentHook(
2736 environments: Record<string, EnvironmentOptions>,
2737 plugins: Plugin[],
2738 logger: Logger,
2739 configEnv: ConfigEnv,
2740 isSsrTargetWebworkerSet: boolean,
2741): Promise<void> {
2742 const context = new BasicMinimalPluginContext<
2743 Omit<PluginContextMeta, 'watchMode'>
2744 >(basePluginContextMeta, logger)
2745
2746 const environmentNames = Object.keys(environments)
2747 for (const p of getSortedPluginsByHook('configEnvironment', plugins)) {
2748 const hook = p.configEnvironment
2749 const handler = getHookHandler(hook)
2750 for (const name of environmentNames) {
2751 const res = await handler.call(context, name, environments[name], {
2752 ...configEnv,
2753 isSsrTargetWebworker: isSsrTargetWebworkerSet && name === 'ssr',
2754 })
2755 if (res) {
2756 environments[name] = mergeConfig(environments[name], res)
2757 }
2758 }
2759 }
2760}
2761
2762function optimizeDepsDisabledBackwardCompatibility(
2763 resolved: ResolvedConfig,

Callers 1

resolveConfigFunction · 0.85

Calls 3

getSortedPluginsByHookFunction · 0.90
getHookHandlerFunction · 0.90
mergeConfigFunction · 0.90

Tested by

no test coverage detected