我在我的网站中使用 Gatsby 版本“2.32.13”,现在我想为我的网站使用 Gatsby 增量构建功能,但由于我的网站托管在 vercel 上,我不想使用 Gatsby Cloud。 那么在不使用 Gatsby Cloud 的情况下,有哪些方法可以实现 Gatsby 增量构建功能
最佳答案
它应该可以在任何 CI/CD 平台(Netlify、Vercel 等)上工作,即使在 Gatsby Cloud 中,实现也容易得多。您只需通过添加环境变量 GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES
来调整部署命令。喜欢:
GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages
注意:--log-pages
标志将帮助您识别每次运行时构建的页面
为了确保跨环境命令支持,我建议安装 cross-env
依赖项并相应地调整前面的命令:
cross-env GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages
给一个full (and official from Gatsby team)关于注意事项的说明:
Conditional Page builds is an experimental feature that only works with data updates. Data updates in Gatsby means, data that comes from the GraphQL layer, in this case only page queries are supported. It can work with JSON updates when using
gatsby-transformer-json
andgatsby-source-filesystem
.Gatsby at this point in time is not going to invest in this feature and it will probably stay experimental without any development.
For more info about our roadmap see https://www.gatsbyjs.com/blog/announcing-unified-gatsby
关于reactjs - 如何在没有 Gatsby 云的情况下使用 Gatsby 功能中的增量构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70976283/