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

[Bug]: --env-mode can‘t change the process.env.NODE_ENV environment variable. #2904

Closed
Fitz6 opened this issue Jul 12, 2024 · 0 comments · Fixed by #2915
Closed

[Bug]: --env-mode can‘t change the process.env.NODE_ENV environment variable. #2904

Fitz6 opened this issue Jul 12, 2024 · 0 comments · Fixed by #2915
Assignees
Labels
🐞 bug Something isn't working

Comments

@Fitz6
Copy link

Fitz6 commented Jul 12, 2024

Version

Browsers:
  Chrome: 126.0.6478.127
  Edge: Chromium (126.0.2592.87)
npmPackages:
  @rsbuild/core: 1.0.0-alpha.9 => 1.0.0-alpha.9

Details

Suppose there is a .env.development file in the project with the following content:

NODE_ENV=development

When you run:

rsbuild build --env-mode development

process.env.NODE_ENV will be set to production instead of development.

However, when using webpack or Vite, process.env.NODE_ENV is correctly set.

For example:
With the same .env.development file, run:

# vite
vite build --mode development

# webpack without dotenv
webpack --mode=development

In these cases, process.env.NODE_ENV is always correctly set to development.

Reproduce link

unnecessary

Reproduce Steps

  1. execute rsbuild build --env-mode development
  2. find the environment variable
@Fitz6 Fitz6 added the 🐞 bug Something isn't working label Jul 12, 2024
@chenjiahan chenjiahan self-assigned this Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants