Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to extend gatsby-config.js #15549

Closed
TidyIQ opened this issue Jul 9, 2019 · 5 comments
Closed

Add option to extend gatsby-config.js #15549

TidyIQ opened this issue Jul 9, 2019 · 5 comments

Comments

@TidyIQ
Copy link

TidyIQ commented Jul 9, 2019

Summary

Add the ability to extend an existing gatsby-config.js. Any additional options added will overwrite the extended config options. Basically, the same implementation as "extends" in tsconfig.json.

Basic example

// gatsby-config.js

module.exports = {
  extends: "path/to/different/gatsby-config.js",
  ...overwrites
}

Motivation

I am creating an npm package that is essentially a template for Gatsby projects. Since it involves many plugins, gatsby-config.js needs to be modified for each project that uses the package. Currently the only options are to:

  1. Force users to copy-paste the gatsby-config.js contents themselves
  2. Clone from a repo

These are poor options as any time the npm package is updated and requires a change in gatsby-config.js (e.g. new plugins are added, settings are changed, plugins removed, etc.), the user has to manually apply the changes themselves to their own gatsby-config.js file.

With this proposed change, users would simply need to run npm update [package_name] and they would immediately receive the new up-to-date configuration file.

This works extremely well for packages such as Typescript and ESLint and it would be fantastic to have this feature in Gatsby.

@lannonbr
Copy link
Contributor

lannonbr commented Jul 9, 2019

Would Gatsby Themes possibly help with this? You can put a base config in the theme and then when you use a theme, the site's gatsby-config is merged with any gatsby-configs from other themes. As well, as you upgrade a theme, the gatsby-config in the theme updates with it so a consumer of the theme doesn't need to touch it.

Here's the docs for Themes: https://www.gatsbyjs.org/docs/themes/what-are-gatsby-themes

@TidyIQ
Copy link
Author

TidyIQ commented Jul 9, 2019

Oh nice, that sounds perfect. I didn't know that was a thing. I'll look into it more, thanks!

@lannonbr
Copy link
Contributor

lannonbr commented Jul 9, 2019

Alright. I'm going to close this for now as this seems to be resolved

@lannonbr lannonbr closed this as completed Jul 9, 2019
@AryanJ-NYC
Copy link

@lannonbr Any idea what I'm doing wrong here? I'm hoping to extend @narative/gatsby-theme-novela's use of gatsby-transformer-remark: https://github.com/AryanJ-NYC/webdev-coach-blog/blob/move-to-narrative/gatsby-config.js#L32.

The links still do not open as expected.

@lannonbr
Copy link
Contributor

Let me open a new issue about this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants