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
Running webpack via webpack-dev-server used to expose an environment variable that allowed you to determine if the application is being served by the dev server. This was quite useful on a React app since you could use this variable to determine when to hydrate the first rendering (SSR) or when to render the full application on first render.
Unfortunately this behaviour is no longer present when running webpack serve. I could replicate this behavior by creating my own env variables for this but it would be a lot more ideal if webpack would do this out of the box. If that's not desirable then I would say that this should at least be included in the migration guide for v5. Mainly because I didn't see a way around using webpack serve due to this issue: webpack/webpack-dev-server#2029 (comment).
What is the current behavior?
When running webpack-dev-server the value of process.env.WEBPACK_DEV_SERVER is set to true.
To Reproduce
Steps to reproduce the behavior:
Place console.log(process.env.WEBPACK_DEV_SERVER); somewhere in your webpack.config.js.
After discussion we solve do not add something to process.env, because it is not good, but now you can use env to achieve this - function format of webpack.config.js
This one really cost me some time: it is a significant change, but not well documented. It's a good candidate for documentation on migrating (but I don't see that anywhere -- am I blind?).
Describe the bug
Running webpack via
webpack-dev-server
used to expose an environment variable that allowed you to determine if the application is being served by the dev server. This was quite useful on a React app since you could use this variable to determine when to hydrate the first rendering (SSR) or when to render the full application on first render.Unfortunately this behaviour is no longer present when running
webpack serve
. I could replicate this behavior by creating my own env variables for this but it would be a lot more ideal if webpack would do this out of the box. If that's not desirable then I would say that this should at least be included in the migration guide for v5. Mainly because I didn't see a way around usingwebpack serve
due to this issue: webpack/webpack-dev-server#2029 (comment).What is the current behavior?
When running
webpack-dev-server
the value ofprocess.env.WEBPACK_DEV_SERVER
is set totrue
.To Reproduce
Steps to reproduce the behavior:
console.log(process.env.WEBPACK_DEV_SERVER);
somewhere in yourwebpack.config.js
.webpack serve
An example can be found here: https://github.com/bensampaio/dev-server-issue.
Expected behavior
I expected the
console.log
to printtrue
.Please paste the results of
webpack-cli info
here, and mention other relevant informationSystem:
Binaries:
Browsers:
Additional context
This issue was originally reported in: webpack/webpack-dev-server#2781.
The text was updated successfully, but these errors were encountered: