Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing --env to webpack serve #2782

Closed
1 of 2 tasks
Eli-Black-Work opened this issue Oct 21, 2020 · 3 comments
Closed
1 of 2 tasks

Passing --env to webpack serve #2782

Eli-Black-Work opened this issue Oct 21, 2020 · 3 comments

Comments

@Eli-Black-Work
Copy link

Eli-Black-Work commented Oct 21, 2020

  • Operating System: Windows 10
  • Node Version: 12.16.3
  • NPM Version: 6.14.4
  • webpack Version: 5.1.3
  • webpack-dev-server Version: 3.11.0
  • Browser: n/a
  • This is a bug
  • This is a modification request

For Features; What is the motivation and/or use-case for the feature?

Now that webpack-dev-server must be invoked via webpack serve, it would be nice if webpack serve accepted --env flags, like webpack-dev-server used to. @mybrainishuge mentioned this in #2759 (comment), and I think it's worth discussing.

As he said:

How are environment options passed to webpack serve when exporting a function in the webpack config? With webpack-dev-server, I passed environment variables:

webpack-dev-server --env.mode development

Passing the same argument to webpack serve errors:

[webpack-cli] Unknown argument: --env.mode
[webpack-cli] Unknown argument: development

I'm not seeing how to pass anything other than booleans to webpack serve, but I want to pass strings:

webpack serve --env mode
@snitin315
Copy link
Member

@Bosch-Eli-Black you can do webpack serve --env mode=development, for more info you can see webpack/webpack-cli#1939

@alexander-akait
Copy link
Member

Answer above, plus it is out of scope webpack-dev-server

@Eli-Black-Work
Copy link
Author

That worked. Thanks, @snitin315 ! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants