Skip to content

Commit

Permalink
Merge pull request #816 from yeatmanlab/ref/318/query-composables-dev…
Browse files Browse the repository at this point in the history
…-tools

Make TanStack Query dev tools load conditionally
  • Loading branch information
maximilianoertel authored Sep 24, 2024
2 parents a9942fe + 6d9316d commit 525349e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
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, onUpdated } from 'vue';
import { computed, onBeforeMount, onMounted, ref, defineAsyncComponent, onUpdated } 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 @@ -101,4 +101,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>

0 comments on commit 525349e

Please sign in to comment.