serverless-webpack
serverless-webpack copied to clipboard
[Docs] Mention Webpack overwriting NODE_ENV when setting "mode"
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.