productionBrowserSourceMaps
开发过程中默认启用源映射。在生产构建期间,它们被禁用以防止你在客户端泄漏源代码,除非你特别选择使用配置标志。
¥Source Maps are enabled by default during development. During production builds, they are disabled to prevent you leaking your source on the client, unless you specifically opt-in with the configuration flag.
Next.js 提供了一个配置标志,你可以使用它在生产构建期间启用浏览器源映射生成:
¥Next.js provides a configuration flag you can use to enable browser source map generation during the production build:
module.exports = {
productionBrowserSourceMaps: true,
}
当启用 productionBrowserSourceMaps
选项时,源映射将输出到与 JavaScript 文件相同的目录中。Next.js 将根据请求自动提供这些文件。
¥When the productionBrowserSourceMaps
option is enabled, the source maps will be output in the same directory as the JavaScript files. Next.js will automatically serve these files when requested.
-
添加源映射可以增加
next build
时间¥Adding source maps can increase
next build
time -
增加
next build
期间的内存使用量¥Increases memory usage during
next build