cli: fix node env not being set for backend dev

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-08-11 15:38:37 +02:00
parent f2ff3c5fb4
commit 72c228fdb8
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Fixed a bug where `NODE_ENV` was not set in the environment when starting the backend in development mode. It has always been the case that Webpack transformed `NODE_ENV` when running in development mode, but this did not affect dependencies in `node_modules` as they are treated as external.
+4
View File
@@ -26,6 +26,10 @@ export async function serveBackend(options: BackendServeOptions) {
isDev: true,
});
// Webpack only replaces occurrences of this in code it touches, which does
// not include dependencies in node_modules. So we set it here at runtime as well.
(process.env as { NODE_ENV: string }).NODE_ENV = 'development';
const compiler = webpack(config, (err: Error | undefined) => {
if (err) {
console.error(err);