This repository was archived by the owner on Jun 2, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +36
-13
lines changed Expand file tree Collapse file tree 5 files changed +36
-13
lines changed Original file line number Diff line number Diff line change 1+ API_PREFIX = api
2+ # if the project uses the API from another server / domain
3+ API_HOST = api.example.com (without protocol)
4+ # use it in case that the frontend is deployed together with the backend
5+ # on the server, so it will enable you to call the backend on the server
6+ PROXY_URL = https://server.example.com
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ typings/
5858
5959# dotenv environment variables file
6060.env
61+ .env. *
62+ ! .env.example
6163
6264# gatsby files
6365.cache /
Original file line number Diff line number Diff line change 11const postcssPresetEnv = require ( 'postcss-preset-env' ) ;
22
3+ const dotenvParsed = require ( './scripts/load-dotenv-config' ) ;
4+ console . log ( `\n\n\n>> gatsby-config.js\n${ JSON . stringify ( dotenvParsed , null , 2 ) } \n\n\n` ) ;
5+
36const gatsbyConfig = {
47 siteMetadata : {
58 title : `Gatsby TypeScript Application Starter` ,
Original file line number Diff line number Diff line change 11const path = require ( 'path' ) ;
22const webpack = require ( 'webpack' ) ;
3- const dotenv = require ( 'dotenv' ) ;
43
5- const activeEnv = process . env . ACTIVE_ENV || process . env . NODE_ENV || 'development' ;
6- const dotenvPath = path . resolve ( __dirname , `.env.${ activeEnv } ` ) ;
7-
8- //www.gatsbyjs.org/docs/environment-variables/
9- const dotenvConfig = dotenv . config ( {
10- path : dotenvPath ,
11- } ) ;
12-
13- if ( dotenvConfig . error ) {
14- console . log ( `\n\n\ndotenv file not found: ${ dotenvPath } \n\n\n` ) ;
15- }
4+ const dotenvParsed = require ( './scripts/load-dotenv-config' ) ;
5+ console . log ( `\n\n\n>> gatsby-node.js\n${ JSON . stringify ( dotenvParsed , null , 2 ) } \n\n\n` ) ;
166
177exports . onCreateWebpackConfig = ( { actions } ) => {
188 // make sure to have the process.env configs from the .env file available on the /src/* files
199 const plugins = [ ] ;
20- const { parsed : dotenvParsed } = dotenvConfig ;
10+ // const { parsed: dotenvParsed } = dotenvConfig;
2111 if ( dotenvParsed ) {
2212 const webpackDefinePluginConfig = { } ;
2313 Object . keys ( dotenvParsed ) . forEach ( key => {
Original file line number Diff line number Diff line change 1+ const path = require ( 'path' ) ;
2+ const dotenv = require ( 'dotenv' ) ;
3+
4+ const activeEnv = process . env . ACTIVE_ENV || process . env . NODE_ENV || 'development' ;
5+ const dotenvPath = path . resolve ( __dirname , '..' , `.env.${ activeEnv } ` ) ;
6+
7+ //www.gatsbyjs.org/docs/environment-variables/
8+ const dotenvConfig = dotenv . config ( {
9+ path : dotenvPath ,
10+ } ) ;
11+
12+ if ( dotenvConfig . error ) {
13+ console . log ( `\n\n\ndotenv file not found: '${ dotenvPath } '\n\n\n` ) ;
14+ }
15+
16+ const { parsed : dotenvParsed } = dotenvConfig ;
17+
18+ if ( dotenvParsed ) {
19+ console . log ( `\n\ndotenv file '${ dotenvPath } ' loaded\n${ JSON . stringify ( dotenvParsed , null , 2 ) } \n\n` ) ;
20+ }
21+
22+ module . exports = dotenvParsed ;
You can’t perform that action at this time.
0 commit comments