实验性预渲染冲突错误
类型:boolean
默认:false
¥Type: boolean
Default: false
astro@5.14.0
在构建过程中将预渲染冲突警告转换为错误。
¥Turns prerender conflict warnings into errors during the build process.
Astro 目前会在构建过程中警告你,如果多个动态路由之间存在冲突,可能会导致相同的输出路径。例如,/blog/[slug] 和 /blog/[...all] 都可能尝试预渲染 /blog/post-1 路径。在这种情况下,Astro 只会渲染冲突路径的 最高优先级路由。这可以确保你的网站成功构建,但你可能会发现某些页面是通过意外的路由渲染的。
¥Astro currently warns you during the build about any conflicts between multiple dynamic routes that can result in the same output path. For example /blog/[slug] and /blog/[...all] both could try to prerender the /blog/post-1 path. In such cases, Astro renders only the highest priority route for the conflicting path. This allows your site to build successfully, although you may discover that some pages are rendered by unexpected routes.
设置此实验性标志后,构建将立即失败并报错。这将要求你立即解决任何路由冲突,并确保 Astro 按照你的预期构建路由。
¥With this experimental flag set, the build will instead fail immediately with an error. This will require you to resolve any routing conflicts immediately, and will ensure that Astro is building your routes as you intend.
要启用此行为,请将 experimental.failOnPrerenderConflict 功能标志添加到 Astro 配置:
¥To enable this behavior, add the experimental.failOnPrerenderConflict feature flag to your Astro config:
import { defineConfig } from "astro/config"
defineConfig({ experimental: { failOnPrerenderConflict: true, },});¥Usage
启用此标志后,尝试构建项目时可能会遇到预渲染路由冲突的错误。如果发生这种情况,你需要更新一个或多个 动态路由 以避免路由歧义。
¥After enabling this flag, you may encounter errors about conflicting prerendered routes when you attempt to build your project. If this happens, you will need to update one or more of your dynamic routes to avoid ambiguous routing.
Reference