Skip to content

Commit c970a2e

Browse files
author
Jordan McDonald
committed
adding support to pass Env param to webpack
1 parent 8d33fa5 commit c970a2e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,10 @@ public class WebpackDevMiddlewareOptions
5050
/// the webpack compiler.
5151
/// </summary>
5252
public IDictionary<string, string> EnvironmentVariables { get; set; }
53+
54+
/// <summary>
55+
/// Pass in the env parameter to webpack.
56+
/// </summary>
57+
public object EnvParam { get; set; }
5358
}
5459
}

src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface DevServerOptions {
3131
HotModuleReplacementServerPort: number;
3232
HotModuleReplacementClientOptions: StringMap<string>;
3333
ReactHotModuleReplacement: boolean;
34+
EnvParam: any;
3435
}
3536

3637
// We support these three kinds of webpack.config.js export. We don't currently support exported promises
@@ -242,7 +243,7 @@ export function createWebpackDevServer(callback: CreateDevServerCallback, option
242243
// In the future, we could add support for configuring the 'env' param in Startup.cs. But right
243244
// now, it's not clear that people will want to do that (and they can always make up their own
244245
// default env values in their webpack.config.js).
245-
webpackConfigExport = webpackConfigExport();
246+
webpackConfigExport = webpackConfigExport(options.suppliedOptions.EnvParam);
246247
}
247248
const webpackConfigArray = webpackConfigExport instanceof Array ? webpackConfigExport : [webpackConfigExport];
248249

0 commit comments

Comments
 (0)