()
| 172 | * Resolve a new instance of the internal chain config with all chain functions applied. |
| 173 | */ |
| 174 | export function resolveChainableConfig(): Config { |
| 175 | const config = new Config(); |
| 176 | |
| 177 | if (!explicitUseConfig) { |
| 178 | useConfig(determineProjectFlavor()); |
| 179 | } |
| 180 | |
| 181 | // apply configs from dependencies |
| 182 | // todo: allow opt-out |
| 183 | applyExternalConfigs(); |
| 184 | |
| 185 | webpackChains |
| 186 | .splice(0) |
| 187 | .sort((a, b) => { |
| 188 | return a.order - b.order; |
| 189 | }) |
| 190 | .forEach(({ chainFn, plugin }) => { |
| 191 | try { |
| 192 | chainFn(config, env); |
| 193 | } catch (err) { |
| 194 | if (plugin) { |
| 195 | // catch and print errors from plugins |
| 196 | return error(` |
| 197 | Unable to apply chain function from: ${plugin}. |
| 198 | Error is: ${err} |
| 199 | `); |
| 200 | } |
| 201 | |
| 202 | // otherwise throw - as the error is likely from the user config |
| 203 | // or missing env flags (eg. missing platform) |
| 204 | throw err; |
| 205 | } |
| 206 | }); |
| 207 | |
| 208 | if (env.verbose) { |
| 209 | info('Resolved chainable config (before merges):'); |
| 210 | info(highlight(config.toString(), { language: 'js' })); |
| 211 | } |
| 212 | |
| 213 | return config; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Resolve a "final" configuration that has all chain functions and merges applied. |
no test coverage detected