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

Decouple the node side code and the browser side code #51

Merged

Conversation

ybbarng
Copy link
Contributor

@ybbarng ybbarng commented Feb 6, 2018

It is important decoupling between the node side code and the browser side code, because it allows to use the rich features of the node side. For example, I wanted to use 'dotenv' to keep my secret keys, but it have to be not exposed to browser side. If it is exposed, the web console complains that there is no module 'fs'. To accomplish this, the 'gatsby-config.js' file (and maybe gatsby-node.js..?) must be kept in node code.
However, it exposed into browser code because the Disqus module imports it directly.
To decouple this, all of the siteMetadata information is served via GraphQL.
This commit has this change.

I am sorry to say that, I couldn't test this PR is working on your repository code because my development environment fails to build this repository.
Anyway, the changes of this PR is similar to my blog's commit and the changes are very straightforward, I think it will work well.
Please test this PR before merge it because of the lack of test.

References:
gatsbyjs/gatsby#2107 (comment)
https://www.gatsbyjs.org/tutorial/part-four/#our-first-graphql-query

It is important that decoupling between node code and browser code.
The 'gatsby-config.js' file must be kept in node code, but it exposed
into browser code because of the Disqus module.
To decouple this, all of the siteMetadata information is served via
GraphQL.
This commit has this change.
@alxshelepenok
Copy link
Owner

@ybbarng Thank you, it seems everything works.

@alxshelepenok alxshelepenok merged commit ccc8c48 into alxshelepenok:master Feb 7, 2018
@ybbarng ybbarng deleted the decoupling-gatsby-config-and-web branch February 9, 2018 04:46
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

Successfully merging this pull request may close these issues.

None yet

2 participants