Skip to content

The WEBPACK_DEV_SERVER environment variable is not set when running "webpack serve" #2781

Closed

Description

@bensampaio
  • Operating System: macOS Catalina 10.15.7
  • Node Version: 12.18.3
  • NPM Version: 6.14.6
  • webpack Version: 5.1.3
  • webpack-dev-server Version: "3.10.3"
  • Browser: any
  • This is a bug
  • This is a modification request

Code

console.log(process.env.WEBPACK_DEV_SERVER);

Put the above in a webpack.config.js executed via:

webpack serve

Expected Behavior

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.

Actual Behavior

undefined is printed.

How can we reproduce the behavior?

Simply place the above console.log inside any webpack.config.js that is run via webpack serve.

Activity

  1. alexander-akait commented on Oct 19, 2020

    @alexander-akait
    Member

    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

  2. bensampaio commented on Oct 20, 2020

    @bensampaio
    Author

    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: #2029 (comment).

    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...

  3. alexander-akait commented on Oct 20, 2020

    @alexander-akait
    Member

    @bensampaio can you provide real use case, maybe we should restore this behavior, it will be easy

  4. alexander-akait commented on Oct 20, 2020

    @alexander-akait
    Member

    @bensampaio I recommend to use --env flags for this, but we can return this behavior, but this need to be fixed in webpack-cli

  5. bensampaio commented on Oct 21, 2020

    @bensampaio
    Author

    @evilebottnawi should I then open a new issue in webpack-cli?

  6. alexander-akait commented on Oct 21, 2020

    @alexander-akait
    Member

    @bensampaio yep please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions