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

Function buildConfig

packages/react-static/src/static/getConfig.js:77–355  ·  view source on GitHub ↗
(state, config = {})

Source from the content-addressed store, hash-verified

75}
76
77export function buildConfig(state, config = {}) {
78 // Default Paths
79 let paths = {
80 root: nodePath.resolve(process.cwd()),
81 src: 'src',
82 dist: 'dist',
83 temp: 'tmp',
84 buildArtifacts: 'artifacts',
85 devDist: 'tmp/dev-server',
86 public: 'public',
87 plugins: 'plugins',
88 pages: 'src/pages',
89 nodeModules: 'node_modules',
90 assets: '',
91 ...(config.paths || {}),
92 }
93
94 // Use the root to resolve all other relative paths
95 const resolvePath = relativePath => nodePath.resolve(paths.root, relativePath)
96
97 // Resolve and replace all pathss
98 const DIST =
99 process.env.REACT_STATIC_ENV === 'development'
100 ? resolvePath(paths.devDist || paths.dist)
101 : resolvePath(paths.dist)
102 const ASSETS = nodePath.resolve(DIST, paths.assets)
103
104 paths = {
105 ROOT: paths.root,
106 SRC: resolvePath(paths.src),
107 DIST,
108 ASSETS,
109 PLUGINS: resolvePath(paths.plugins),
110 TEMP: resolvePath(paths.temp),
111 ARTIFACTS: resolvePath(paths.buildArtifacts),
112 PUBLIC: resolvePath(paths.public),
113 NODE_MODULES: resolvePath(paths.nodeModules),
114 EXCLUDE_MODULES:
115 paths.excludeResolvedModules || resolvePath(paths.nodeModules),
116 PACKAGE: resolvePath('package.json'),
117 HTML_TEMPLATE: nodePath.join(DIST, 'index.html'),
118 STATIC_DATA: nodePath.join(ASSETS, 'staticData'),
119 }
120
121 // siteRoot, basePath, publicPath, and assetPath resolution
122 let siteRoot = ''
123 let basePath = ''
124 let assetsPath = ''
125 if (process.env.REACT_STATIC_ENV === 'development') {
126 basePath = cleanSlashes(config.devBasePath)
127 assetsPath = config.devAssetsPath || paths.assets || assetsPath
128 } else if (state.staging) {
129 siteRoot = cutPathToRoot(config.stagingSiteRoot || '/', '$1')
130 basePath = cleanSlashes(config.stagingBasePath)
131 assetsPath = config.stagingAssetsPath || paths.assets || assetsPath
132 } else {
133 siteRoot = cutPathToRoot(config.siteRoot || '/', '$1')
134 basePath = cleanSlashes(config.basePath)

Callers 3

getConfig.test.jsFile · 0.90
getConfigFunction · 0.85
buildConfigFromPathFunction · 0.85

Calls 4

cleanSlashesFunction · 0.90
cutPathToRootFunction · 0.90
isAbsoluteUrlFunction · 0.90
resolvePathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…