0

For a typescript library added to a Nx monorepo without build configuration (Vite):

.env file is created in the root of the project: redux

enter image description here

Accessing using dotenv: config.ts

import * as dotenv from 'dotenv';

dotenv.config();

export const APP_SECRET_KEY = process.env.APP_SECRET_KEY || '';
export const DATABASE_URL = process.env.DATABASE_URL || '';

The exported components from this library are used in a app (React+Vite)

Browser is giving the error

enter image description here

Nx docs have given instructions for using environment variables for node and Vite configured apps/libs.

PS: No need of adding Vite for the existing lib as it's not a react component library

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.