Browse Source

refactor: Add dotenv support in medusa-config.js

Oliver Windall Juhl 3 years ago
parent
commit
90ecf50363
3 changed files with 584 additions and 314 deletions
  1. 1 1
      .gitignore
  2. 24 0
      medusa-config.js
  3. 559 313
      yarn.lock

+ 1 - 1
.gitignore

@@ -4,4 +4,4 @@
 /uploads
 /node_modules
 yarn-error.log
-
+/.idea

+ 24 - 0
medusa-config.js

@@ -1,3 +1,27 @@
+const dotenv = require('dotenv')
+
+let ENV_FILE_NAME = '';
+switch (process.env.NODE_ENV) {
+	case 'production':
+		ENV_FILE_NAME = '.env.production';
+		break;
+	case 'staging':
+		ENV_FILE_NAME = '.env.staging';
+		break;
+	case 'test':
+		ENV_FILE_NAME = '.env.test';
+		break;
+	case 'development':
+	default:
+		ENV_FILE_NAME = '.env';
+		break;
+}
+
+try {
+	dotenv.config({ path: process.cwd() + '/' + ENV_FILE_NAME });
+} catch (e) {
+}
+
 // CORS when consuming Medusa from admin
 const ADMIN_CORS = process.env.ADMIN_CORS || "http://localhost:7000,http://localhost:7001";
 

File diff suppressed because it is too large
+ 559 - 313
yarn.lock


Some files were not shown because too many files changed in this diff