why below code run in the development mode? it should only run in production mode
Here is the running scripts in package.json
"build-watch-dev": "vite build --mode development --watch",
import { useStore } from '@/store';
import { register } from 'register-service-worker';

export function registerSW() {
    if (import.meta.env.PROD) {
        register(`${import.meta.env.BASE_URL}service-worker.js`, {
            ready() {
                console.log(
                    'App is being served from cache by a service worker.\n' +
                    'For more details, visit 
                )
            },
            registered() {
                console.log('Service worker has been registered.')
            },
            cached() {
                console.log('Content has been cached for offline use.')
            },
            updatefound() {
                console.log('New content is downloading.')
            },
            updated() {
                console.log('New content is available; please refresh.');
                const $store = useStore();
                $store.serviceWorkerUpdate = true;
            },
            offline() {
                console.log('No internet connection found. App is running in offline mode.')
            },
            error(error) {
                const $store = useStore();
                if ($store.isOnline) {
                    console.error('Error during service worker registration:', error)
                }
            }
        })
    }
}


import.meta.env.PROD runs in development mode
The --mode flag overrides the value of import.meta.env.MODE.
import.meta.env.PROD is effectively a boolean result of process.env.NODE_ENV === 'production'
You could try changing your conditional to something like:
if (import.meta.env.MODE !== 'development') {

Or you could look at setting NODE_ENV to development.
