From 670f11902706a80a7e3b68022283b03aa61a5093 Mon Sep 17 00:00:00 2001 From: Ignacio Lizana Date: Tue, 7 Oct 2025 15:57:14 +0200 Subject: [PATCH 1/2] feat: add option to disable service worker --- src/index.js | 2 +- webpack.config.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index c55a1b1c5..dabd62d18 100755 --- a/src/index.js +++ b/src/index.js @@ -36,7 +36,7 @@ i18n const root = ReactDOM.createRoot(document.getElementById('app')); root.render(); -if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { +if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator && process.env.SERVICE_WORKER_DISABLED !== 'true') { window.addEventListener('load', () => { navigator.serviceWorker.register('service-worker.js') .catch((registrationError) => { diff --git a/webpack.config.js b/webpack.config.js index ea1685592..4c40e322a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -213,6 +213,7 @@ module.exports = (env, argv) => ({ new webpack.EnvironmentPlugin({ SENTRY_DSN: null, ...env, + SERVICE_WORKER_DISABLED: false, DEBUG: argv.mode !== 'production', VERSION: pachageJson.version, COMMIT_HASH From 57571cf1fc2a437d8f3a81368a77133a635fde80 Mon Sep 17 00:00:00 2001 From: Ignacio Lizana <70455159+NachoLZ@users.noreply.github.com> Date: Tue, 7 Oct 2025 17:44:23 +0200 Subject: [PATCH 2/2] fix: Handle boolean value for SERVICE_WORKER_DISABLED The `webpack.EnvironmentPlugin` provides the default value for `SERVICE_WORKER_DISABLED` as a boolean (`false`). The previous implementation only checked for the string `'true'`, which would fail to correctly identify the boolean `true` case, causing the feature to not work as intended when the variable was set without being explicitly a string. This commit updates the conditional check to handle both the boolean `true` and the string `'true'` to ensure the service worker is reliably disabled. Co-authored-by: Tim --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index dabd62d18..519d32589 100755 --- a/src/index.js +++ b/src/index.js @@ -36,7 +36,7 @@ i18n const root = ReactDOM.createRoot(document.getElementById('app')); root.render(); -if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator && process.env.SERVICE_WORKER_DISABLED !== 'true') { +if (process.env.NODE_ENV === 'production' && process.env.SERVICE_WORKER_DISABLED !== 'true' && process.env.SERVICE_WORKER_DISABLED !== true && 'serviceWorker' in navigator) { window.addEventListener('load', () => { navigator.serviceWorker.register('service-worker.js') .catch((registrationError) => {