-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuxt.config.ts
More file actions
144 lines (134 loc) · 4.3 KB
/
nuxt.config.ts
File metadata and controls
144 lines (134 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import fs from "node:fs";
import path from "node:path";
import type { H3Context } from "@open-xamu-co/firebase-nuxt/server";
import {
debugCSS,
debugNuxt,
production,
firebaseConfig,
} from "@open-xamu-co/firebase-nuxt/server/environment";
import { type Stylesheet, getStyleSheetPreload } from "@open-xamu-co/ui-nuxt";
import {
debugScrapper,
debugHTTPS,
cfScrapeCoursesUrl,
cfScrapeCourseGroupsUrl,
} from "./server/utils/enviroment";
import packageJson from "./package.json" assert { type: "json" };
const loaderCss = fs.readFileSync(path.resolve(__dirname, "app/assets/loader.css"), {
encoding: "utf8",
});
const css = [];
const stylesheets: Stylesheet[] = [
"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500;1,600&display=swap",
"https://unpkg.com/@fortawesome/fontawesome-free@^6/css/all.min.css",
"https://unpkg.com/sweetalert2@^11/dist/sweetalert2.min.css",
];
// compile on runtime when debuggin CSS
debugCSS.value() ? css.push("assets/vendor.scss") : stylesheets.push("/dist/vendor.min.css?k=1");
// Metadata
const withResolutions = "resolutions" in packageJson && debugNuxt.value();
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: "2025-03-02",
// Follow nuxt 4 directory structure
srcDir: "./app",
serverDir: "./server",
dir: { public: "../public" },
app: {
pageTransition: { name: "page", mode: "out-in" },
layoutTransition: { name: "layout", mode: "out-in" },
head: {
htmlAttrs: { lang: "es" },
meta: [
{ charset: "utf-8" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{ name: "msvalidate.01", content: "BBF99508118DB02449397517DA5EAE5C" },
],
link: [
{ rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
{
rel: "preconnect",
href: "https://fonts.googleapis.com/",
crossorigin: "anonymous",
},
{ rel: "dns-prefetch", href: "https://fonts.googleapis.com/" },
{ rel: "preconnect", href: "https://unpkg.com/", crossorigin: "anonymous" },
{ rel: "dns-prefetch", href: "https://unpkg.com/" },
...stylesheets.map(getStyleSheetPreload),
],
style: [{ innerHTML: loaderCss, tagPriority: 0 }],
noscript: [{ innerHTML: "This app requires javascript to work" }],
},
},
devServer: { https: debugHTTPS.value() && { key: "server.key", cert: "server.crt" } },
runtimeConfig: {
debugScrapper: debugScrapper.value(),
cfScrapeCoursesUrl: cfScrapeCoursesUrl.value(),
cfScrapeCourseGroupsUrl: cfScrapeCourseGroupsUrl.value(),
public: {
debugHTTPS: debugHTTPS.value(),
},
},
vite: {
css: {
postcss: require("@open-xamu-co/ui-styles/postcss")[
production.value() ? "production" : "development"
],
preprocessorOptions: {
scss: {
additionalData: `
@use "assets/overrides";
@use "@open-xamu-co/ui-styles/src/utils/module" as xamu;`,
},
},
},
server: { fs: { strict: !withResolutions } },
},
nitro: {
preset: "firebase_app_hosting",
routeRules: {
// Support firebase auth proxy for signing with redirect
"/__/**": {
proxy: `https://${firebaseConfig.value().projectId}.firebaseapp.com/__/**`,
},
},
rollupConfig: {
external: withResolutions
? [
"firebase-admin/app",
"firebase-admin/firestore",
"firebase-admin/auth",
"firebase-admin/storage",
]
: undefined,
},
},
/** Global CSS */
css,
modules: ["@open-xamu-co/firebase-nuxt", "@nuxt/scripts"],
firebaseNuxt: {
readCollection: (collectionId: string, { currentAuth }: H3Context) => {
/** Freely listable collections */
const listableCollections = [];
// Auth, Allow listing if admin or above
if (currentAuth && currentAuth.role <= -1) {
listableCollections.push("logs", "instances", "offenders", "proxies");
}
return listableCollections.includes(collectionId);
},
readInstanceCollection: (collectionId: string, { currentAuth }: H3Context) => {
/** Freely listable collections */
const listableCollections = ["courses"];
// Auth required
if (currentAuth) {
// Auth, Allow listing if admin or above
if (currentAuth.role <= -1) listableCollections.push("logs");
}
return listableCollections.includes(collectionId);
},
},
scripts: {
registry: { googleAnalytics: { id: firebaseConfig.value().measurementId } },
},
});