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

[Docs] Mention Webpack overwriting NODE_ENV when setting "mode" #1009

Open
eegli opened this issue Nov 20, 2021 · 0 comments
Open

[Docs] Mention Webpack overwriting NODE_ENV when setting "mode" #1009

eegli opened this issue Nov 20, 2021 · 0 comments

Comments

@eegli
Copy link

eegli commented Nov 20, 2021

Proposal: Update docs about Webpack setting/overwriting process.env.NODE_ENV.

Description

Currently, the example for setting mode in the Webpack config does not mention that setting mode (e.g. using slsw.lib.webpack.isLocal) will overwrite process.env.NODE_ENV. In larger Serverless projects, multiple stages may be specified in serverless.yml. If any serverless function has NODE_ENV set as one of their environment variables, webpack will overwrite it with either production or development.

In many cases, people will likely want to declare env variables in serverless.yml and use Webpack primarily for bundling while still getting the benefits of Webpack's mode.

I suggest updating the docs to mention optimization.nodeEnv, which will tell Webpack not to set process.env.NODE_ENV. It may be useful for people who want their serverless config file as the single source of truth for env variables and don't know that setting mode would, by default, have an impact on them.

If okay for you, I can open a PR with a suggestion.

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

1 participant