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 <tymmesyde@gmail.com>
This commit is contained in:
Ignacio Lizana 2025-10-07 17:44:23 +02:00 committed by GitHub
parent 670f119027
commit 57571cf1fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -36,7 +36,7 @@ i18n
const root = ReactDOM.createRoot(document.getElementById('app')); const root = ReactDOM.createRoot(document.getElementById('app'));
root.render(<App />); root.render(<App />);
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', () => { window.addEventListener('load', () => {
navigator.serviceWorker.register('service-worker.js') navigator.serviceWorker.register('service-worker.js')
.catch((registrationError) => { .catch((registrationError) => {