1.1.1 • Published 2 years ago

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

Weekly downloads
-
License
MIT
Repository
github
Last release
2 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

2 years ago

1.0.9

2 years ago

1.0.10

2 years ago

1.1.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago