I built a static website using gatsbyJS and prismic.io as a headless CMS. Does anybody know how to use different configs when building the website (gatsby build) ( for example : gatsby config 1 / gatsby config 2). The end goal is to use Jenkins to auto build different sites with the same code base but different css/config.
How can you use different configs when you build a website (gatsby build)
595 Views Asked by Jules-B At
1
There are 1 best solutions below
Related Questions in JENKINS
- How to export credentials from one jenkins instance to another?
- JENKINS Maven Build Failure
- Why does the Jenkins SVN plugin give error E170001 when connecting to my VisualSVN server?
- Jenkins build is stuck pending
- Some of my tests show prepended with junit.framework
- Restrict number of instances of a build in the queue
- how to generate xml report using python-green for unit testing and coverage?
- Behave test runner has no colored output on Jenkins
- Test Selector Plugin Jenkins returns No tests were executed
- jenkins with groovy postbuild .Not able to execute anything in groovy script field
- Not able to build maven project using Maven configured with Jenkins
- Sonnar runner in Jenkins error in java project
- How can I read build.xml parameters into Jenkins ?
- Cannot access file on Jenkins slave with plugin
- Excluding jobs that haven't run recently from a view in Jenkins
Related Questions in GATSBY
- How to get images from contentful using the natural width (resolution)?
- When to use a react framework such as Next or Gatsby vs Create React App
- Is it possible to use d3.js with gatsby.js framework?
- Choose createPages gatsby component based on server side rendering or browser rendering
- Page props do not update when url query is updated
- How are searches implemented in a Flat File CMS
- How do I run a graqphl query in gatsby-browser.js
- Is it possible to query all entries from a content type and filter the response based on a subfield?
- sitemap for gatsby-starter-blog
- How do I setup .less with a gatsby project?
- Gatsby language localization Mdx files with gatsby-plugin-intl
- Using HTML placeholders in React
- react components state null gatsby
- Background image not showing up on iOS devices
- Gatsby blog not showing all post, only posts of month on course
Related Questions in PRISMIC.IO
- Problem with Client Components in Nextjs 13 and Prismic.io
- Animate NextJS image onLoad (when inView)
- Getting around Prismic's lack of <blockquote> element capability in rich text editor
- Best practice for repeated react components
- NextJS & Prismic - How to prevent /:uid from rendering homepage
- Next.js is not building page as SSG when it should
- How can you use different configs when you build a website (gatsby build)
- How to modify a long paragraph string and insert html tags into it based on a list of modifiers?
- Nuxt handle fetch errors from Prismic API
- Nuxt: Show splash animation once per session
- Typescript types for Prismic Slices
- Material UI customize property behind classes
- How to create nested Repeater/Group Fields in Prismic Slices
- How can I render tags from Rich Text Editor in Prismic React Client?
- Generate sitemap according prismic data in Nuxt
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Well, it's not exactly using "different
gatsby-config.js" files but the most similar approach is using environment variables. This will allow you to use the samegatsby-config.jswith different setups.Gatsby by default uses
developmentandproductionas environments when runninggatsby developandgatsby buildrespectively (you can override this behavior as desired using your custom environments). In that way, you need to tell Gatsby where are those variables set. This is done by the following snippet (ingatsby-config.js):If you create a
.env.developmentand.env.productionat the root of your project, you can simply do:Now, in any configuration parameter, you can use the environment variables stored in those files like:
Extending this behavior, you can customize the running commands to use different environment files like
.env.siteOneand.env.siteTwosimply changing and creating your own scripts in yourpackage.jsonand using theGATSBY_ACTIVE_ENVvariable:Just running:
You will be taking the environment variables stored in the
.env.siteOnefile so you can point to a different CMS configuration, different theming, different routes, and paths, etc.Disclaimer: the whole process aims to use server-side variables to change some configuration/parameters. To use the client-side (JavaScript) variables you can omit the
require("dotenv").config({ path: `.env.${process.env.NODE_ENV}`})part.