Fix Cloudflare Pages build (#1285)

* fix(temp): remove box shadows from tailwind config

* fix(temp): "polyfill" global during build process

* refactor: use `import.meta` instead of deprecated `process`

* oops: replace `process.server` as well
This commit is contained in:
Evan Song 2024-07-10 22:17:04 -07:00 committed by GitHub
parent 04ba76aac8
commit c20242cf1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 25 additions and 30 deletions

View File

@ -80,6 +80,14 @@ export default defineNuxtConfig({
}, },
}, },
vite: { vite: {
define: {
global: {},
},
esbuild: {
define: {
global: "globalThis",
},
},
cacheDir: "../../node_modules/.vite/apps/knossos", cacheDir: "../../node_modules/.vite/apps/knossos",
resolve: { resolve: {
dedupe: ["vue"], dedupe: ["vue"],

View File

@ -3,7 +3,7 @@ import { Card } from "@modrinth/ui";
import VueApexCharts from "vue3-apexcharts"; import VueApexCharts from "vue3-apexcharts";
// let VueApexCharts // let VueApexCharts
// if (process.client) { // if (import.meta.client) {
// VueApexCharts = defineAsyncComponent(() => import('vue3-apexcharts')) // VueApexCharts = defineAsyncComponent(() => import('vue3-apexcharts'))
// } // }

View File

@ -85,7 +85,7 @@ function useLoadingIndicator(opts: { duration: number; throttle: number }) {
function start() { function start() {
clear(); clear();
progress.value = 0; progress.value = 0;
if (opts.throttle && process.client) { if (opts.throttle && import.meta.client) {
_throttle = setTimeout(() => { _throttle = setTimeout(() => {
isLoading.value = true; isLoading.value = true;
_startTimer(); _startTimer();
@ -113,7 +113,7 @@ function useLoadingIndicator(opts: { duration: number; throttle: number }) {
function _hide() { function _hide() {
clear(); clear();
if (process.client) { if (import.meta.client) {
setTimeout(() => { setTimeout(() => {
isLoading.value = false; isLoading.value = false;
setTimeout(() => { setTimeout(() => {
@ -124,7 +124,7 @@ function useLoadingIndicator(opts: { duration: number; throttle: number }) {
} }
function _startTimer() { function _startTimer() {
if (process.client) { if (import.meta.client) {
_timer = setInterval(() => { _timer = setInterval(() => {
_increase(step.value); _increase(step.value);
}, 100); }, 100);

View File

@ -1,12 +1,12 @@
export const useBaseFetch = async (url, options = {}, skipAuth = false) => { export const useBaseFetch = async (url, options = {}, skipAuth = false) => {
const config = useRuntimeConfig(); 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) { if (!options.headers) {
options.headers = {}; options.headers = {};
} }
if (process.server) { if (import.meta.server) {
options.headers["x-ratelimit-key"] = config.rateLimitKey; options.headers["x-ratelimit-key"] = config.rateLimitKey;
} }

View File

@ -48,7 +48,7 @@ export const updateTheme = (value, updatePreference = false) => {
if (updatePreference) theme.value.preference = value; if (updatePreference) theme.value.preference = value;
} }
if (process.client) { if (import.meta.client) {
document.documentElement.className = `${theme.value.value}-mode`; document.documentElement.className = `${theme.value.value}-mode`;
} }

View File

@ -654,7 +654,7 @@ const navRoutes = computed(() => [
]); ]);
onMounted(() => { onMounted(() => {
if (window && process.client) { if (window && import.meta.client) {
window.history.scrollRestoration = "auto"; window.history.scrollRestoration = "auto";
} }
@ -667,7 +667,7 @@ watch(
isMobileMenuOpen.value = false; isMobileMenuOpen.value = false;
isBrowseMenuOpen.value = false; isBrowseMenuOpen.value = false;
if (process.client) { if (import.meta.client) {
document.body.style.overflowY = "scroll"; document.body.style.overflowY = "scroll";
document.body.setAttribute("tabindex", "-1"); document.body.setAttribute("tabindex", "-1");
document.body.removeAttribute("tabindex"); document.body.removeAttribute("tabindex");

View File

@ -1500,7 +1500,7 @@ const collapsedChecklist = ref(false);
const showModerationChecklist = ref(false); const showModerationChecklist = ref(false);
const futureProjects = ref([]); 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; showModerationChecklist.value = true;
futureProjects.value = history.state.projects; futureProjects.value = history.state.projects;
} }

View File

@ -779,7 +779,7 @@ export default defineNuxtComponent({
featured: false, featured: false,
}; };
// For navigation from versions page / upload file prompt // 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; replaceFile = history.state.newPrimaryFile;
try { try {

View File

@ -130,7 +130,7 @@ useHead({
const user = await useUser(); const user = await useUser();
const auth = await useAuth(); const auth = await useAuth();
if (process.client) { if (import.meta.client) {
await initUserFollows(); await initUserFollows();
} }

View File

@ -152,7 +152,7 @@ async function readAll() {
function changePage(newPage) { function changePage(newPage) {
page.value = newPage; page.value = newPage;
if (process.client) { if (import.meta.client) {
window.scrollTo({ top: 0, behavior: "smooth" }); window.scrollTo({ top: 0, behavior: "smooth" });
} }
} }

View File

@ -465,7 +465,7 @@ const {
} = useLazyFetch( } = useLazyFetch(
() => { () => {
const config = useRuntimeConfig(); 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}`]; const params = [`limit=${maxResults.value}`, `index=${sortType.value.name}`];
@ -589,7 +589,7 @@ function onSearchChange(newPageNumber) {
refreshSearch(); refreshSearch();
if (process.client) { if (import.meta.client) {
const obj = getSearchUrl((currentPage.value - 1) * maxResults.value, true); const obj = getSearchUrl((currentPage.value - 1) * maxResults.value, true);
router.replace({ path: route.path, query: obj }); router.replace({ path: route.path, query: obj });
} }
@ -751,7 +751,7 @@ function toggleEnv(environment, sendRequest) {
} }
function onSearchChangeToTop(newPageNumber) { function onSearchChangeToTop(newPageNumber) {
if (process.client) { if (import.meta.client) {
window.scrollTo({ top: 0, behavior: "smooth" }); window.scrollTo({ top: 0, behavior: "smooth" });
} }

View File

@ -5,7 +5,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
const cosmetics = useCosmetics(); const cosmetics = useCosmetics();
nuxtApp.hook("app:mounted", () => { 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 colorSchemeQueryList = window.matchMedia("(prefers-color-scheme: light)");
const setColorScheme = (e) => { const setColorScheme = (e) => {

View File

@ -120,19 +120,6 @@ module.exports = {
rawBg: "var(--landing-raw-bg)", 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: [], plugins: [],