enablePrerenderSourceMaps
在 next build 期间为预渲染过程中的错误启用 source maps。
enablePrerenderSourceMaps 选项让 Node.js 在 next build 的预渲染阶段使用现有的 source maps。当 source maps 可用时,错误堆栈跟踪会指向原始源代码。它默认为 true。
此选项不会生成 source maps。webpack 默认不会生成服务器端 source maps。要在排查预渲染错误时生成它们,请使用 next build --debug-prerender。
要禁用它,请将 enablePrerenderSourceMaps 设置为 false:
next.config.ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
enablePrerenderSourceMaps: false,
}
export default nextConfignext.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
enablePrerenderSourceMaps: false,
}
module.exports = nextConfig参考#
| 选项 | 类型 | 默认值 |
|---|---|---|
enablePrerenderSourceMaps | boolean | true |
在预渲染期间禁用 source maps 可以减少构建内存占用,但会使预渲染错误更难调试。
版本历史#
| 版本 | 变更 |
|---|---|
v16.3.0 | 默认值改为 true,无论是否启用了 cacheComponents。 |
v16.0.0 | enablePrerenderSourceMaps 从 experimental.enablePrerenderSourceMaps 移至顶层 enablePrerenderSourceMaps 选项。 |