From e76bad601da65351cd85b95380f893065ffe8902 Mon Sep 17 00:00:00 2001 From: savage <2443005004@qq.com> Date: Sun, 8 Oct 2023 01:30:47 +0800 Subject: [PATCH] feat: add new options --environment for pass additional settings to the config file via process.env --- src/cli-main.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cli-main.ts b/src/cli-main.ts index b3338b6c..2d723f99 100644 --- a/src/cli-main.ts +++ b/src/cli-main.ts @@ -96,6 +96,10 @@ export async function main(options: Options = {}) { 'Signal to kill child process, "SIGTERM" or "SIGKILL"' ) .option('--cjsInterop', 'Enable cjs interop') + .option( + '--environment ', + 'Pass additional settings to the config file via process.env' + ) .action(async (files: string[], flags) => { const { build } = await import('.') Object.assign(options, { @@ -148,6 +152,13 @@ export async function main(options: Options = {}) { } }, {}) } + if (flags.environment) { + const environment = flags.environment as string + environment.split(',').forEach((v) => { + const [key, value] = v.split(':') + process.env[key] = value || 'true' + }) + } await build(options) })