From 2133ef2e508c31731fe1eef81c066c98a8b006b1 Mon Sep 17 00:00:00 2001 From: Taras Date: Fri, 28 Apr 2023 13:08:38 +0300 Subject: [PATCH] chore: add support for passing env variables (#25) --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index e45041b..00b50b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ export type RunScriptWebpackPluginOptions = { autoRestart?: boolean; args: string[]; cwd?: string; + env?: NodeJS.ProcessEnv | undefined; keyboard: boolean; name?: string; nodeArgs: string[]; @@ -123,13 +124,14 @@ export class RunScriptWebpackPlugin implements WebpackPluginInstance { }; private _startServer(cb: (arg0: ChildProcess) => void): void { - const { args, nodeArgs, cwd } = this.options; + const { args, nodeArgs, cwd, env } = this.options; if (!this._entrypoint) throw new Error('run-script-webpack-plugin requires an entrypoint.'); const child = fork(this._entrypoint, args, { execArgv: nodeArgs, stdio: 'inherit', cwd, + env, }); setTimeout(() => cb(child), 0); }