@investtal/vite-runtime-env
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Vite-plugin-runtime-env

Problem

The default Vite config mechanism doesn't separate code and env following 12-Factors

Solution

This plugin solves the problem above by separating the env config into a separate module from the code bundle, opening the door for mounting and updating runtime config when running in a container environment.

Usage

Declare env following Vite convention: https://vitejs.dev/guide/env-and-mode.html .env.production

.vite.config.ts

import RuntimeEnv from '@investtal/vite-runtime-env';
import ViteReactRefresh from '@vitejs/plugin-react';
import { UserConfig } from 'vite';

const config: UserConfig = {
  plugins: [...plugins, RuntimeEnv()],
};

client code:

console.log(window.__RUNTIME_ENV__);
console.log(window.__APP_METADATA__);

Readme

Keywords

none

Package Sidebar

Install

npm i @investtal/vite-runtime-env

Weekly Downloads

13

Version

1.1.0

License

MIT

Unpacked Size

16.9 kB

Total Files

11

Last publish

Collaborators

  • nhattq.coding
  • thanh.nd
  • hieudtr8