diff --git a/packages/frontend/src/main.ts b/packages/frontend/src/main.ts index 408bd98e..97d5a102 100644 --- a/packages/frontend/src/main.ts +++ b/packages/frontend/src/main.ts @@ -22,7 +22,7 @@ import 'uno.css'; import '#/assets/styles/index.css'; /** - * - VUE PLUGINS, STORE AND DIRECTIVE - + * - Vue.js PLUGINS, STORE AND DIRECTIVE - * The order of statements IS IMPORTANT */ const remote = createRemote(); @@ -55,3 +55,15 @@ await document.fonts.ready; * MOUNTING POINT */ app.mount(document.body); + +/** + * DEV-MODE LOGIC + */ +if (import.meta.env.DEV) { + /* eslint-disable-next-line unicorn/no-lonely-if */ + if (import.meta.hot) { + const { handleHotUpdate } = await import('vue-router/auto-routes'); + + handleHotUpdate(router); + } +} diff --git a/packages/frontend/src/plugins/router/index.ts b/packages/frontend/src/plugins/router/index.ts index ef22db1e..18c14de0 100644 --- a/packages/frontend/src/plugins/router/index.ts +++ b/packages/frontend/src/plugins/router/index.ts @@ -4,7 +4,6 @@ import { createWebHashHistory, createWebHistory } from 'vue-router'; -import { handleHotUpdate } from 'vue-router/auto-routes'; import { isStr } from '@jellyfin-vue/shared/validation'; import { remote } from '../remote/index.ts'; import { adminGuard } from './middlewares/admin-pages.ts'; @@ -22,9 +21,7 @@ export const router = createRouter({ /** * TODO: Fix this, so it only scrolls to the top once suspense resolves */ - scrollBehavior(_to, _from, savedPosition) { - return savedPosition ?? { top: 0 }; - } + scrollBehavior: (_to, _from, savedPosition) => savedPosition ?? { top: 0 } }); /** @@ -76,7 +73,3 @@ watch([ force: true }); }, { flush: 'sync' }); - -if (import.meta.hot) { - handleHotUpdate(router); -}