Skip to content

Commit

Permalink
Add dotenv for environment variable loading
Browse files Browse the repository at this point in the history
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
  • Loading branch information
THORSTEN SCHMINKEL committed Feb 12, 2024
1 parent 11701a4 commit efb92cd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -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());

Expand Down

0 comments on commit efb92cd

Please sign in to comment.