(state, config = {})
| 75 | } |
| 76 | |
| 77 | export 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) |
no test coverage detected
searching dependent graphs…