console.log(process.env.WEBPACK_DEV_SERVER);
Put the above in a webpack.config.js executed via:
webpack serve
I would expect the console.log to print true or 1. I am not sure what used to be the value for this environment variable but I am sure it used to be there.
undefined is printed.
Simply place the above console.log inside any webpack.config.js that is run via webpack serve.
WEBPACK_DEV_SERVER only for custom running, no WEBPACK_DEV_SERVER in webpack.config.js, because we can't know about it, you can use multi compiler mode, you can use env variables for this
Well it used to work when running webpack-dev-server directly so why doesn't it work with webpack serve? After upgrading to webpack 5 I had to change to webpack serve because webpack-dev-server didn't work anymore due to this issue: https://github.com/webpack/webpack-dev-server/issues/2029#issuecomment-707034614.
If this was expected behavior with the transition to webpack 5 then I would at least expect this to be documented in the migration guide instead of closing this issue as if was meant to be obvious that this is not possible...
@bensampaio can you provide real use case, maybe we should restore this behavior, it will be easy
@evilebottnawi would this help: https://github.com/bensampaio/dev-server-issue ?
@bensampaio I recommend to use --env flags for this, but we can return this behavior, but this need to be fixed in webpack-cli
@evilebottnawi should I then open a new issue in webpack-cli?
@bensampaio yep please
Most helpful comment
Well it used to work when running
webpack-dev-serverdirectly so why doesn't it work withwebpack serve? After upgrading to webpack 5 I had to change towebpack servebecausewebpack-dev-serverdidn't work anymore due to this issue: https://github.com/webpack/webpack-dev-server/issues/2029#issuecomment-707034614.If this was expected behavior with the transition to webpack 5 then I would at least expect this to be documented in the migration guide instead of closing this issue as if was meant to be obvious that this is not possible...