gatsby - 增量构建 Netlify + Gatsby 不工作

标签 gatsby netlify

我一直在尝试使用增量构建来设置 Gatsby + Netlify,但我无法让它工作。 Gatsby 总是认为每个页面都需要更新。有谁知道我能做什么?

查看日志。我使用 Gatsby 缓存,但它更新了我没有接触过的页面。

 PM: ​
12:08:07 PM: ❯ Loading plugins
12:08:07 PM:    - netlify-plugin-gatsby-cache@0.2.2 from netlify.toml and package.json
12:08:08 PM: ​
12:08:08 PM: ┌────────────────────────────────────────────────────────┐
12:08:08 PM: │ 1. onPreBuild command from netlify-plugin-gatsby-cache │
12:08:08 PM: └────────────────────────────────────────────────────────┘
12:08:08 PM: ​
12:08:11 PM: Found a Gatsby cache. We’re about to go FAST. ⚡️
12:08:11 PM: ​
12:08:11 PM: (netlify-plugin-gatsby-cache onPreBuild completed in 3.2s)
12:08:11 PM: ​
12:08:11 PM: ┌────────────────────────────────────┐
12:08:11 PM: │ 2. build.command from netlify.toml │
12:08:11 PM: └────────────────────────────────────┘
12:08:11 PM: ​
12:08:11 PM: $ npm run build
12:08:11 PM: > gatsby-starter-default@0.1.0 build /opt/build/repo
12:08:11 PM: > GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages
12:08:14 PM: success open and validate gatsby-configs - 0.063s
12:08:18 PM: success load plugins - 4.496s
12:10:15 PM: Updated page: /companies/helse-bemanning/
12:10:15 PM: Updated page: /companies/helse-bemanning/lon/
12:10:15 PM: Updated page: /companies/helse-bemanning/recensioner/
12:10:15 PM: Updated page: /companies/helse-bemanning/jobb/
12:10:15 PM: Updated page: /companies/annsam/
12:10:15 PM: Updated page: /companies/annsam/lon/
12:10:15 PM: Updated page: /companies/annsam/recensioner/
12:10:15 PM: Updated page: /companies/annsam/jobb/
12:10:15 PM: Updated page: /companies/medicarrera/
12:10:15 PM: Updated page: /companies/medicarrera/lon/
12:10:15 PM: Updated page: /companies/medicarrera/recensioner/
12:10:15 PM: Updated page: /companies/medicarrera/jobb/
12:10:15 PM: Updated page: /companies/coliva/
12:10:15 PM: Updated page: /companies/coliva/lon/
12:10:15 PM: Updated page: /companies/coliva/recensioner/
12:10:15 PM: Updated page: /companies/coliva/jobb/
12:10:15 PM: Updated page: /companies/vacant/
12:10:15 PM: Updated page: /companies/vacant/lon/
12:10:15 PM: Updated page: /companies/vacant/recensioner/

最佳答案

2022 年更新

netlify-plugin-gatsby-cache 已捆绑在 netlify-plugin-gatsby 中,以及更多功能,因此新配置应按以下方式处理:

  [[plugins]]
  package = "@netlify/plugin-gatsby"

在您的根项目文件夹中,创建一个名为 netlify.toml 的文件,内容如下:

[[plugins]]
    package = "netlify-plugin-gatsby-cache"

然后,在 Netlify 中安装插件: Netlify plugin page

就是这样。您不需要设置任何命令,Gatsby + Netlify 将完成剩下的工作。您的下一次部署:

9:49:34 PM: ┌────────────────────────────────────────────────────────┐
9:49:34 PM: │ 1. onPreBuild command from netlify-plugin-gatsby-cache │
9:49:34 PM: └────────────────────────────────────────────────────────┘
9:49:34 PM: ​
9:49:36 PM: Found a Gatsby cache. We’re about to go FAST. ⚡️
9:49:36 PM: ​
9:49:36 PM: (netlify-plugin-gatsby-cache onPreBuild completed in 1.7s)

关于gatsby - 增量构建 Netlify + Gatsby 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62801108/

相关文章:

javascript - Netlify Vue 构建找不到导出模块

javascript - 如何将全栈应用程序部署到heroku或netlify?哪些文件是必需的?

aws-lambda - 如何在 Netlify lambda 函数之间共享代码

javascript - 对 GraphQL 查询进行随机排序

heroku - 在 Netlify 站点的自定义子域上获取 'Not Found'。将 Route53 与托管在 Heroku 上的 Netlify 和子域一起使用

graphql - 如何在多种类型上使用 GraphQL 片段

javascript - GraphQL 查询错误它说未知类型 "ContentfulSizes"

vue.js - 如何将 Vue Webpack-simple app 部署到 Netlify?

node.js - 这是有效的 Node.js 要求吗? "const { EXAMPLE.SOMETHING } = require (' 示例')"

javascript - JS 不在 Gatsby 上运行