Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TanStack Query dev tools load conditionally #816

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/firebase-hosting-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
- name: 'vite staging build'
env:
NODE_OPTIONS: '--max_old_space_size=8192'
run: export VITE_STAGING_BUILD=true && npm ci && npm run build
VITE_STAGING_BUILD: true
VITE_QUERY_DEVTOOLS_ENABLED: true
run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
Expand Down
25 changes: 19 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@
<SessionTimer v-if="loadSessionTimeoutHandler" />
</div>

<VueQueryDevtools />
<VueQueryDevtools v-if="showDevtools" />
</template>

<script setup>
// @TODO: Make conditional import for local dev environment only.
import { VueQueryDevtools } from '@tanstack/vue-query-devtools';

import { computed, onBeforeMount, ref, defineAsyncComponent } from 'vue';
import { computed, onBeforeMount, onMounted, ref, defineAsyncComponent } from 'vue';
import { useRoute } from 'vue-router';
import { useRecaptchaProvider } from 'vue-recaptcha';
import { Head } from '@unhead/vue/components';

import NavBar from '@/components/NavBar.vue';

const SessionTimer = defineAsyncComponent(() => import('@/containers/SessionTimer/SessionTimer.vue'));
const VueQueryDevtools = defineAsyncComponent(() =>
import('@tanstack/vue-query-devtools').then((module) => module.VueQueryDevtools),
);

import { useAuthStore } from '@/store/auth';
import { fetchDocById } from '@/helpers/query/utils';
import { i18n } from '@/translations/i18n';

const isLevante = import.meta.env.MODE === 'LEVANTE';
const isAuthStoreReady = ref(false);
const showDevtools = ref(false);

const authStore = useAuthStore();
const route = useRoute();
Expand Down Expand Up @@ -98,4 +98,17 @@ onBeforeMount(async () => {
});
isAuthStoreReady.value = true;
});

onMounted(() => {
const isLocal = import.meta.env.MODE === 'development';
const isDevToolsEnabled = import.meta.env.VITE_QUERY_DEVTOOLS_ENABLED === 'true';

if (isLocal) {
showDevtools.value = true;
} else if (isDevToolsEnabled) {
window.toggleDevtools = () => {
showDevtools.value = !showDevtools.value;
};
}
});
</script>
Loading