reactjs - 如何在没有 Gatsby 云的情况下使用 Gatsby 功能中的增量构建

标签 reactjs gatsby vercel gatsby-plugin gatsby-cloud

我在我的网站中使用 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 and gatsby-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/

相关文章:

reactjs - 使用 sessionStorage 刷新时 React 状态对象变成 "[object Object]"

javascript - 通过状态传递 onChange 事件

javascript - 使用 React 和 Gatsby 将 Prop 从 parent 传递给 child

graphql - GraphQL 的多语言支持

javascript - 注册账号后出现登录禁止信息

reactjs - 通过标题中的按钮导航到不同的屏幕

reactjs - 如何使用 React 有条件地渲染来自 2 个数据源的数据

javascript - 如何使用 Gatsby 在 Netlify 上获取多步骤表单

javascript - Nest.js 部署到 now.sh

next.js - 对象字面量只能指定已知属性,并且 'x' 不存在于类型 (prisma) 中