From efb92cd933b8451645ea823f4656c9634a68c7eb Mon Sep 17 00:00:00 2001 From: THORSTEN SCHMINKEL Date: Mon, 12 Feb 2024 17:17:22 +0100 Subject: [PATCH] Add dotenv for environment variable loading Installed dotenv library for handling environment variables in the project. Changes include adding dotenv into the package.json and package-lock.json files, and using dotenv.config() in the vite --- package-lock.json | 12 ++++++++++++ package.json | 1 + vite.config.js | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/package-lock.json b/package-lock.json index 6848455..3fc01ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@headlessui/react": "^1.7.18", "@heroicons/react": "^2.1.1", "@tailwindcss/forms": "^0.5.7", + "dotenv": "^16.4.2", "react": "^18.2.0", "react-dom": "^18.2.0", "react-select": "^5.8.0", @@ -1534,6 +1535,17 @@ "csstype": "^3.0.2" } }, + "node_modules/dotenv": { + "version": "16.4.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.2.tgz", + "integrity": "sha512-rZSSFxke7d9nYQ5NeMIwp5PP+f8wXgKNljpOb7KtH6SKW1cEqcXAz9VSJYVLKe7Jhup/gUYOkaeSVyK8GJ+nBg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", diff --git a/package.json b/package.json index 233c5f6..fda4ace 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@headlessui/react": "^1.7.18", "@heroicons/react": "^2.1.1", "@tailwindcss/forms": "^0.5.7", + "dotenv": "^16.4.2", "react": "^18.2.0", "react-dom": "^18.2.0", "react-select": "^5.8.0", diff --git a/vite.config.js b/vite.config.js index b97e3e8..e0ca15d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,8 +1,14 @@ import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; +import dotenv from 'dotenv'; + +dotenv.config(); // load env vars from .env file // This function is exported for Vite to use as configuration export default ({ mode }) => { + + console.log("### (vite.config.js) process.env: ", process.env); + // Load app-level env vars specific to the current mode const env = loadEnv(mode, process.cwd());