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)
608 Views Asked by Jules-B At
1
There are 1 best solutions below
Related Questions in JENKINS
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
Related Questions in GATSBY
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
Related Questions in PRISMIC.IO
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
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 # Hahtags
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.js
with different setups.Gatsby by default uses
development
andproduction
as environments when runninggatsby develop
andgatsby build
respectively (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.development
and.env.production
at 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.siteOne
and.env.siteTwo
simply changing and creating your own scripts in yourpackage.json
and using theGATSBY_ACTIVE_ENV
variable:Just running:
You will be taking the environment variables stored in the
.env.siteOne
file 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.