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

Fix Cloudflare Pages build #1285

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions apps/frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export default defineNuxtConfig({
},
},
vite: {
define: {
global: {},
},
esbuild: {
define: {
global: "globalThis",
},
},
cacheDir: "../../node_modules/.vite/apps/knossos",
resolve: {
dedupe: ["vue"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Card } from "@modrinth/ui";
import VueApexCharts from "vue3-apexcharts";

// let VueApexCharts
// if (process.client) {
// if (import.meta.client) {
// VueApexCharts = defineAsyncComponent(() => import('vue3-apexcharts'))
// }

Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/components/ui/modrinth-loading-indicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function useLoadingIndicator(opts: { duration: number; throttle: number }) {
function start() {
clear();
progress.value = 0;
if (opts.throttle && process.client) {
if (opts.throttle && import.meta.client) {
_throttle = setTimeout(() => {
isLoading.value = true;
_startTimer();
Expand Down Expand Up @@ -113,7 +113,7 @@ function useLoadingIndicator(opts: { duration: number; throttle: number }) {

function _hide() {
clear();
if (process.client) {
if (import.meta.client) {
setTimeout(() => {
isLoading.value = false;
setTimeout(() => {
Expand All @@ -124,7 +124,7 @@ function useLoadingIndicator(opts: { duration: number; throttle: number }) {
}

function _startTimer() {
if (process.client) {
if (import.meta.client) {
_timer = setInterval(() => {
_increase(step.value);
}, 100);
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/composables/fetch.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const useBaseFetch = async (url, options = {}, skipAuth = false) => {
const config = useRuntimeConfig();
let base = process.server ? config.apiBaseUrl : config.public.apiBaseUrl;
let base = import.meta.server ? config.apiBaseUrl : config.public.apiBaseUrl;

if (!options.headers) {
options.headers = {};
}

if (process.server) {
if (import.meta.server) {
options.headers["x-ratelimit-key"] = config.rateLimitKey;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/composables/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const updateTheme = (value, updatePreference = false) => {
if (updatePreference) theme.value.preference = value;
}

if (process.client) {
if (import.meta.client) {
document.documentElement.className = `${theme.value.value}-mode`;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ const navRoutes = computed(() => [
]);

onMounted(() => {
if (window && process.client) {
if (window && import.meta.client) {
window.history.scrollRestoration = "auto";
}

Expand All @@ -667,7 +667,7 @@ watch(
isMobileMenuOpen.value = false;
isBrowseMenuOpen.value = false;

if (process.client) {
if (import.meta.client) {
document.body.style.overflowY = "scroll";
document.body.setAttribute("tabindex", "-1");
document.body.removeAttribute("tabindex");
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/pages/[type]/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ const collapsedChecklist = ref(false);

const showModerationChecklist = ref(false);
const futureProjects = ref([]);
if (process.client && history && history.state && history.state.showChecklist) {
if (import.meta.client && history && history.state && history.state.showChecklist) {
showModerationChecklist.value = true;
futureProjects.value = history.state.projects;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/pages/[type]/[id]/version/[version].vue
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ export default defineNuxtComponent({
featured: false,
};
// For navigation from versions page / upload file prompt
if (process.client && history.state && history.state.newPrimaryFile) {
if (import.meta.client && history.state && history.state.newPrimaryFile) {
replaceFile = history.state.newPrimaryFile;

try {
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/pages/dashboard/collections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ useHead({
const user = await useUser();
const auth = await useAuth();

if (process.client) {
if (import.meta.client) {
await initUserFollows();
}

Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/pages/dashboard/notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async function readAll() {

function changePage(newPage) {
page.value = newPage;
if (process.client) {
if (import.meta.client) {
window.scrollTo({ top: 0, behavior: "smooth" });
}
}
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/pages/search/[searchProjectType].vue
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ const {
} = useLazyFetch(
() => {
const config = useRuntimeConfig();
const base = process.server ? config.apiBaseUrl : config.public.apiBaseUrl;
const base = import.meta.server ? config.apiBaseUrl : config.public.apiBaseUrl;

const params = [`limit=${maxResults.value}`, `index=${sortType.value.name}`];

Expand Down Expand Up @@ -589,7 +589,7 @@ function onSearchChange(newPageNumber) {

refreshSearch();

if (process.client) {
if (import.meta.client) {
const obj = getSearchUrl((currentPage.value - 1) * maxResults.value, true);
router.replace({ path: route.path, query: obj });
}
Expand Down Expand Up @@ -751,7 +751,7 @@ function toggleEnv(environment, sendRequest) {
}

function onSearchChangeToTop(newPageNumber) {
if (process.client) {
if (import.meta.client) {
window.scrollTo({ top: 0, behavior: "smooth" });
}

Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/plugins/1.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
const cosmetics = useCosmetics();

nuxtApp.hook("app:mounted", () => {
if (process.client && themeStore.value.preference === "system") {
if (import.meta.client && themeStore.value.preference === "system") {
const colorSchemeQueryList = window.matchMedia("(prefers-color-scheme: light)");

const setColorScheme = (e) => {
Expand Down
13 changes: 0 additions & 13 deletions apps/frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,6 @@ module.exports = {
rawBg: "var(--landing-raw-bg)",
},
},
boxShadow: {
insetLg: "var(--shadow-inset-lg)",
inset: "var(--shadow-inset)",
insetSm: "var(--shadow-inset-sm)",
raisedLg: "var(--shadow-raised-lg)",
raised: "var(--shadow-raised)",
floating: "var(--shadow-floating)",
card: "var(--shadow-card)",
landing: {
blobShadow: "var(--landing-blob-shadow)",
cardShadow: "var(--landing-card-shadow)",
},
},
},
},
plugins: [],
Expand Down