跳到内容

generateBuildId

Next.js 在 next build 期间生成一个 ID,用于标识正在提供的应用程序版本。相同的构建应被使用并启动多个容器。

如果您为环境的每个阶段重建,您将需要生成一个一致的构建 ID 以在容器之间使用。在 next.config.js 中使用 generateBuildId 命令

next.config.js
module.exports = {
  generateBuildId: async () => {
    // This could be anything, using the latest git hash
    return process.env.GIT_HASH
  },
}