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)
599 views Asked by Jules-B At
1
There are 1 answers
Related Questions in JENKINS
- Shellscript touch command not working in jenkins pipeline
- Jenkins Docker Agent Configuration Issue: Connection Refused on Local Ubuntu Install
- How to add more input text box in dynamicreferenceparameter in jenkins
- Jenkins pipeline script: Accept merge request from Gitlab
- Jenkins Exec Format Error while cloning repo
- Post checkmarx scan weblink on the Jenkins Build status page
- Exclude a file from merging to the main branch
- Created Jenkins pipeline and added the script in the Pipeline Description.To check out the Project from the svn repository.NotWorking. Any Suggestion
- How to write a Jenkins Pipeline script to fetch needed repo?
- trouble to trigger Jenkins job
- Unable to start jenkins in amazon linux 2: start request repeated too quickly
- is not a valid Cucumber report! String length (20054016) exceeds the maximum length (20000000)
- Run cleanup function in Python when Jenkins job is aborted
- Jenkins pipeline map is getting converted to an array but it's too large I think?
- How do I list which Jenkins credentials used per pipeline in the script console?
Related Questions in GATSBY
- Gatsby create nodes dynamically with json fetch
- gatsby + netlify cms images not loading
- tsv file at path isn't found when running locally with Gatsby
- Warning package.json: No license field $ TARGET_ENV='dev' gatsby develop
- Build errors when running gatsby build after using getServerData() for SSR page
- Gatsby - ReferenceError: Cannot access 'u' before initialization
- How to fetch all the keywords from the database in Gatsby
- Gatsby 5+ and gatsby-plugin-preact error "renderToPipeableStream is not a function"
- WebpackError: ReferenceError: document is not defined with lottie-react
- How to upload images via Gatsby Azure Static Web App into Azure Database
- Error: Inline JavaScript is not enabled - Gatsby with gatsby-plugin-less and gatsby-plugin-antd
- Gatsby hydration error on production but everything works fine locally
- Cannot find module '@reach/router' after using @gatsbyjs/reach-router
- Commenting in a Gatsby website + wordpress CMS
- gatsby-node.js file throws an error after uploading to Gatsby Azure Static Web App
Related Questions in PRISMIC.IO
- Error using 'use client' in Prismic CMS and Nextjs 14 with app router
- Module not found: Can't resolve '@/prismicio'
- Getting data out from Prismic based on type and value of a field
- Animate NextJS image onLoad (when inView)
- Problem with Client Components in Nextjs 13 and Prismic.io
- Gatsby, Prismic with GraphQl query aliases error
- Prismic filters - error 500 when field not available in prismic
- Properly typing Prismic Content Relationships
- How do I dynamically generate pages with Next.js when route contains special characters?
- Typing error in a prismic app with a ContentRelationshipField
- How to fetch data using App Routes from NextJS and Prismic? I'm currently only being able to render uid fields
- NextJs Fetch Data from Prismic blocked by CORS
- Module ‘”@prismicio/client”’ has no exported member ‘Content’ error on build on Vercel
- How can I connect to multiple Prismic repositories in a Next.js project?
- Emiting values to slice-zone Prismic
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?
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)
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.