admin管理员组

文章数量:1313121

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

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

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

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

本文标签: viteHow to use environment variables in a typescript library with NXStack Overflow