MCPcopy Index your code
hub / github.com/react-static/react-static / getConfig

Function getConfig

packages/react-static/src/static/getConfig.js:22–69  ·  view source on GitHub ↗
(
  state,
  callback = async config => {
    if (state.debug) {
      console.log('getConfig():')
      console.log(state)
    }
    return config
  }
)

Source from the content-addressed store, hash-verified

20
21// Retrieves the static.config.js from the current project directory
22export default function getConfig(
23 state,
24 callback = async config => {
25 if (state.debug) {
26 console.log('getConfig():')
27 console.log(state)
28 }
29 return config
30 }
31) {
32 const configPath =
33 state.configPath ||
34 state.packageConfig.config ||
35 DEFAULT_PATH_FOR_STATIC_CONFIG
36
37 state = {
38 ...state,
39 originalConfig: configPath,
40 }
41
42 const resolvedPath = nodePath.resolve(configPath)
43
44 const noConfig =
45 configPath === DEFAULT_PATH_FOR_STATIC_CONFIG && !resolvedPath
46
47 if (noConfig) {
48 // last
49 state = buildConfig(state, defaultConfig)
50 return callback(state).catch(console.error)
51 }
52
53 state = buildConfigFromPath(state, resolvedPath || configPath)
54
55 if (state.stage === 'dev') {
56 chokidar
57 .watch(resolvedPath, {
58 ignoreInitial: true,
59 })
60 .on('all', async () => {
61 console.log('')
62 console.log(`Updating static.config.js`)
63 state = buildConfigFromPath(state, resolvedPath)
64 callback(state).catch(console.error)
65 })
66 }
67
68 return callback(state).catch(console.error)
69}
70
71function buildConfigFromPath(state, configPath) {
72 delete require.cache[configPath]

Callers 6

getConfig.test.jsFile · 0.85
start.jsFile · 0.85
bundle.jsFile · 0.85
export.jsFile · 0.85
getWebpackConfigFunction · 0.85

Calls 2

buildConfigFunction · 0.85
buildConfigFromPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…