This was pulled from #4518, it can already be merged so it's easier to get it in.
* Allow next.config.js to export a function * Expose phases to the configuration function * Use same value as variable name * Add next/constants * Add documentation for config function / phases * Add constants.js to npm bundle