1.1.1 • Published 3 years ago

@techmely/vite-plugin-runtime-env v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Vite-plugin-runtime-env

Problem

Cơ chế sẵn có của Vite không cho phép phân tách code và env theo chuẩn 12-Factors

Solution

Plugin này giải quyết vấn đề trên bằng cách tách config env ra 1 module riêng khỏi code bundle, mở ra cánh cửa cho việc mount và update config runtime khi chạy trên môi trường container.

Usage

Khai báo env như convention của Vite: https://vitejs.dev/guide/env-and-mode.html .env.production

ENV=production
USER_API_URL=https://services.user.com

.vite.config.ts

import ViteRuntimeEnv from '@techmely/vite-plugin-runtime-env';
import { UserConfig } from 'vite';

const config: UserConfig = {
  plugins: [ViteRuntimeEnv()]
};

client code:

console.log(window._env_.ENV); // "production"
1.1.1

3 years ago

1.0.9

3 years ago

1.0.10

3 years ago

1.1.0

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago