MCPcopy Create free account
hub / github.com/chakra-ui/panda / loadConfigAndCreateContext

Function loadConfigAndCreateContext

packages/node/src/config.ts:30–64  ·  view source on GitHub ↗
(options: { cwd?: string; config?: Config; configPath?: string } = {})

Source from the content-addressed store, hash-verified

28 * Used by the CLI and PostCSS plugin.
29 */
30export async function loadConfigAndCreateContext(options: { cwd?: string; config?: Config; configPath?: string } = {}) {
31 const { config, configPath } = options
32
33 const cwd = options.cwd ?? options?.config?.cwd ?? process.cwd()
34 const conf = await loadConfig({ cwd, file: configPath })
35
36 if (config) {
37 Object.assign(conf.config, config)
38 }
39
40 if (options.cwd) {
41 conf.config.cwd = options.cwd
42 }
43
44 if (conf.config.lightningcss && !conf.config.browserslist) {
45 conf.config.browserslist ||= browserslist.findConfig(cwd)?.defaults
46 }
47
48 // Auto-inject built-in plugins (vue, svelte, lightningcss)
49 // Auto plugins run first, then the already-resolved user hooks run after
50 const autoPlugins = getAutoPlugins(conf.config)
51
52 // conf.hooks is already properly merged from user plugins + inline hooks by resolveConfig.
53 // Prepend auto-plugins before it — don't re-process user plugins to avoid double-execution.
54 conf.hooks = mergeHooks([...autoPlugins, { name: RESOLVED_HOOKS_NAME, hooks: conf.hooks }])
55 conf.config.plugins = [...autoPlugins, ...(conf.config.plugins ?? [])]
56
57 const tsConfResult = await loadTsConfig(conf, cwd)
58
59 if (tsConfResult) {
60 Object.assign(conf, tsConfResult)
61 }
62
63 return new PandaContext(conf)
64}

Callers 5

loadPandaConfigFunction · 0.90
mainFunction · 0.90
startMcpServerFunction · 0.90
BuilderClass · 0.90
generateFunction · 0.90

Calls 5

loadConfigFunction · 0.90
mergeHooksFunction · 0.90
loadTsConfigFunction · 0.90
getAutoPluginsFunction · 0.85
cwdMethod · 0.65

Tested by

no test coverage detected