digitalbazaar / bedrock-webpack

Bedrock webpack module.
Apache License 2.0
0 stars 2 forks source link

Only define process.env.NODE_ENV in production. #24

Closed davidlehn closed 4 years ago

davidlehn commented 4 years ago

I'm unsure if there are any unintended side effects of this in other modules.

davidlehn commented 4 years ago

@gannan08 The situation is a bit more absurd than that at the moment. Looking for suggestions on how it should be improved. Setting NODE_ENV when building would just set that for the builder itself. The current code uses flags to set modes for the target. Best to do node app.js bundle --bundle-mode production now, which sets the optimize flag for bedrock-webpack, which then sets up this define. There's also a --webpack-mode that can be used to be explicit. I was trying to leave the option open to build a production site but in development mode. Which could be useful for extreme debugging. This is all sadly a bit confusing.

Using "NODE_ENV" in the frontend code is also a cause for confusion (it's not node). When this was written I couldn't find another common name though, and some other projects already were using this pattern, wise or not.

I'll just leave all that here as a long winded way of saying this needs work but will do for now. I'll file an issue.