From 33629b945d8268db171aed95b42475518f615795 Mon Sep 17 00:00:00 2001
From: Tilman Vatteroth <git@tilmanvatteroth.de>
Date: Thu, 4 May 2023 20:52:00 +0200
Subject: [PATCH] fix(frontend): use standalone output only in production build

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
---
 frontend/next.config.js          | 4 ++--
 frontend/src/utils/test-modes.js | 9 ++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/frontend/next.config.js b/frontend/next.config.js
index 8aed11b9c..edde6ec72 100644
--- a/frontend/next.config.js
+++ b/frontend/next.config.js
@@ -3,7 +3,7 @@
  *
  * SPDX-License-Identifier: AGPL-3.0-only
  */
-const { isMockMode, isTestMode } = require('./src/utils/test-modes')
+const { isMockMode, isTestMode, isProductionMode} = require('./src/utils/test-modes')
 const path = require('path')
 const CopyWebpackPlugin = require('copy-webpack-plugin')
 const withBundleAnalyzer = require('@next/bundle-analyzer')({
@@ -86,7 +86,7 @@ const rawNextConfig = {
       }
     ])
   },
-  output: 'standalone',
+  output: isProductionMode ? 'standalone' : undefined,
   swcMinify: false, //Otherwise emoji picker is minified incorrectly
   experimental: {
     outputFileTracingRoot: path.join(__dirname, '../')
diff --git a/frontend/src/utils/test-modes.js b/frontend/src/utils/test-modes.js
index bc411835d..0530dff54 100644
--- a/frontend/src/utils/test-modes.js
+++ b/frontend/src/utils/test-modes.js
@@ -37,8 +37,15 @@ const isMockMode = !!process.env.NEXT_PUBLIC_USE_MOCK_API && isPositiveAnswer(pr
  */
 const isDevMode = process.env.NODE_ENV === 'development'
 
+/**
+ * Defines if the current runtime was built in production mode.
+ * @type boolean
+ */
+const isProductionMode = process.env.NODE_ENV === 'production'
+
 module.exports = {
   isTestMode,
   isMockMode,
-  isDevMode
+  isDevMode,
+  isProductionMode
 }