[英]Is it possible to run a build for particular change in Gatsby Project?
When I run the build for Gatsby project it is taking more than 1.30 HR because of lot of lot of dynamic pages.当我为 Gatsby 项目运行构建时,由于有很多动态页面,它花费了超过1.30 HR 。 My question is when I make a change on a particular page or pages Is it possible to run the build for the particular changes?我的问题是当我对一个或多个特定页面进行更改时是否可以针对特定更改运行构建?
For gatsby develop
try using Gatsby flags .对于gatsby develop
尝试使用Gatsby flags 。 Used like this in the gatsby-config.js
:在gatsby-config.js
中这样使用:
module.exports = {
flags: {
FAST_DEV: true,
},
}
You can find a full detailed explanation of the current available flags at: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/utils/flags.ts您可以在以下位置找到当前可用标志的完整详细说明: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/utils/flags.ts
In your case, try using FAST_DEV
which includes PRESERVE_FILE_DOWNLOAD_CACHE
and DEV_WEBPACK_CACHE
flags respectively.在您的情况下,请尝试使用分别包含PRESERVE_FILE_DOWNLOAD_CACHE
和FAST_DEV
标志的DEV_WEBPACK_CACHE
。
For gatsby build
I think you are looking for a feature called Incremental Builds: which basically only builds the pages that have changed from the last deployment.对于gatsby build
,我认为您正在寻找一种称为增量构建的功能:它基本上只构建自上次部署以来发生更改的页面。
Depending on your deploy server there's a different implementation way:根据您的部署服务器,有不同的实现方式:
Netlify: https://www.netlify.com/blog/2020/04/23/enable-gatsby-incremental-builds-on.netlify/ Netlify: https://www.netlify.com/blog/2020/04/23/enable-gatsby-incremental-builds-on.netlify/
Gatsby Cloud: https://www.gatsbyjs.com/blog/2020-04-22-announcing-incremental-builds/盖茨比云: https://www.gatsbyjs.com/blog/2020-04-22-announcing-incremental-builds/
Custom implementation: this is difficult to handle without a server implementation, which will be different in each case (and details have not been provided in the question).自定义实现:如果没有服务器实现,这很难处理,每种情况都会有所不同(问题中未提供详细信息)。 Try adapting Netlify's answer by enabling GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES
and `cross-env , leaving your deploy command like:尝试通过启用GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES
和`cross-env来调整 Netlify 的答案,将部署命令保留为:
"build": "cross-env GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.