It would be nice have some params on gatsby build to choose which pages in /pages will be build
Somehting like gatsby build --pages index.js,about-us,contact
We are running a very large gatsby project and we generate single pages as needed. So each time I move everything from /pages to /pages.tmp and only generate what I need.
Thank you for opening this!
This isn't something we want to implement this way. For "only generating what changed" we have Incremental Builds now.
Gatsby uses gatsby-plugin-page-creator for src/pages. So you could place the pages you might want to or not want to build into a separate folder, use that plugin and e.g. pass in a ignore regex via ENV variables into the plugin options.
The ENV var then could be set inside the script call like cross-env IGNORE_PATTERN=index.js gatsby build.
require('dotenv').config()
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/indexes/pages`,
ignore: [process.env.IGNORE_PATTERN],
// See pattern syntax recognized by micromatch
// https://www.npmjs.com/package/micromatch#matching-features
},
},
],
}
We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!
Thanks for documenting how to generate a page from src/pages.
Is there a way to generate only a specific set of pages created from a data source (e.g. GraphQL) via createPages in gatsby-node?