Skip to content

Commit

Permalink
feat: ensure all resources are loaded before mount (#2430)
Browse files Browse the repository at this point in the history
Signed-off-by: Fernando Fernández <[email protected]>
  • Loading branch information
ferferga committed Aug 17, 2024
1 parent e3637d5 commit 9ddffb1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions frontend/src/assets/styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import url('@fontsource-variable/figtree');
@import url('@unocss/reset/tailwind-compat.css');
@import url('./global.css');
18 changes: 9 additions & 9 deletions frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* for TypeScript compiler (check tsconfig.json)
* https://caniuse.com/mdn-javascript_operators_await_top_level
*/
import { createApp } from 'vue';
import { createApp, effectScope } from 'vue';
import { routes } from 'vue-router/auto-routes';
import { useEventListener } from '@vueuse/core';
import Root from '@/App.vue';
import { hideDirective } from '@/plugins/directives';
import { vuePlugin as i18n } from '@/plugins/i18n';
Expand All @@ -14,19 +15,15 @@ import { vuetify } from '@/plugins/vuetify';
/**
* - GLOBAL STYLES -
*/
import '@fontsource-variable/figtree';
/* eslint-disable-next-line import/no-extraneous-dependencies */
import '@unocss/reset/tailwind-compat.css';
import 'uno.css';
import 'virtual:unocss-devtools';
import '@/assets/styles/global.css';
import '@/assets/styles/index.css';

/**
* - VUE PLUGINS, STORE AND DIRECTIVE -
* The order of statements IS IMPORTANT
*/
const remote = createRemote();

const app = createApp(Root);

/**
Expand All @@ -44,10 +41,13 @@ app.use(vuetify);
app.directive('hide', hideDirective);

/**
* This ensures the transition plays: https://router.vuejs.org/guide/migration/#all-navigations-are-now-always-asynchronous
* Also ensures Suspense component's content has loaded on first navigation (refer to RouterViewTransition component)
* Ensure everything is fully loaded before mounting the app
*/
await router.isReady();
await Promise.all([
router.isReady(),
...[...document.fonts.keys()].map(font => font.load())
]);
await document.fonts.ready;

/**
* MOUNTING POINT
Expand Down

0 comments on commit 9ddffb1

Please sign in to comment.