From 7c07beb494f462ab70a0801c5e20fa66bf047ebc Mon Sep 17 00:00:00 2001 From: Jordan McDonald Date: Fri, 6 Oct 2017 15:41:05 -0500 Subject: [PATCH] adding support to pass Env param to webpack --- .../Webpack/WebpackDevMiddlewareOptions.cs | 5 +++++ .../npm/aspnet-webpack/src/WebpackDevMiddleware.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs b/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs index 7ef0f1735e..d4fcfa9aa0 100644 --- a/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs +++ b/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddlewareOptions.cs @@ -50,5 +50,10 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack /// the webpack compiler. /// public IDictionary EnvironmentVariables { get; set; } + + /// + /// Pass in the env parameter to webpack. + /// + public object EnvParam { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts index a160f835ed..1f20cc5871 100644 --- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts +++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts @@ -32,6 +32,7 @@ interface DevServerOptions { HotModuleReplacementServerPort: number; HotModuleReplacementClientOptions: StringMap; ReactHotModuleReplacement: boolean; + EnvParam: any; } // We support these three kinds of webpack.config.js export. We don't currently support exported promises @@ -248,7 +249,7 @@ export function createWebpackDevServer(callback: CreateDevServerCallback, option // In the future, we could add support for configuring the 'env' param in Startup.cs. But right // now, it's not clear that people will want to do that (and they can always make up their own // default env values in their webpack.config.js). - webpackConfigExport = webpackConfigExport(); + webpackConfigExport = webpackConfigExport(options.suppliedOptions.EnvParam); } const webpackConfigArray = webpackConfigExport instanceof Array ? webpackConfigExport : [webpackConfigExport];