You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
I've got the following webpack.config.js file in which I've added a guard clause to check that the build environment is properly injected (as it should be for webpack 2).
module.exports=function(env){if(env==null){console.log("Environment is not set up. Webpack needs --env.dev or --env.prod arguments, passed to module.exports function(env)");thrownewError("Environment is not set up. Webpack needs --env.dev or --env.prod arguments, passed to module.exports function(env)");}if(env.prod){returnrequire('./config/webpack.prod.js');}else{returnrequire('./config/webpack.dev.js');}}
However, when I try to run the application with hot module replacement (i.e. in development), env is undefined.
check that the build environment is properly injected (as it should be for webpack 2)
I'm not sure it's really correct to say "should be for webpack 2". The env param is best understood as optional, since invoking webpack on the command line (on its own, with no args), will result in your function being invoked with no env value.
However, I understand that you want some way of forcing WebpackDevMiddleware to pass some env value. There isn't currently a good way of doing that. But if you want to implement support for it, you could add a new property, EnvParameter (type: object) on WebpackDevMiddlewareOptions.cs, so that it gets serialized and included in the CreateDevServerOptions received by WebpackDevMiddleware.ts. Then you could simply pass that object to webpackConfigExport on WebpackDevMiddleware.ts line 222. If you're interested in submitting a pull request along those lines, I'd be happy to merge it!
Closing this as by design, but as described above, we'd be happy to add a new feature to make this more flexible if you want, and if you're able to do a PR for it. Thanks!
Hi,
I've got the following
webpack.config.js
file in which I've added a guard clause to check that the build environment is properly injected (as it should be for webpack 2).However, when I try to run the application with hot module replacement (i.e. in development),
env
is undefined.The Code in
Startup.cs
looks like this:How can I fix this? (
process.argv.indexOf
is no longer supported in webpack 2)The text was updated successfully, but these errors were encountered: