drop/server/nuxt.config.ts

306 lines
6.6 KiB
TypeScript
Raw Permalink Normal View History

import tailwindcss from "@tailwindcss/vite";
import { execSync } from "node:child_process";
import { readFileSync, existsSync } from "node:fs";
import path from "node:path";
import module from "node:module";
import { fileURLToPath } from "node:url";
import { type } from "arktype";
2024-10-25 13:15:46 +11:00
const packageJsonSchema = type({
name: "string",
version: "string",
});
const twemojiPackage = module.findPackageJSON(
"@discordapp/twemoji",
import.meta.url,
);
if (!twemojiPackage) {
throw new Error("Could not find @discordapp/twemoji package.");
}
const twemojiAssetsPath = path.join(
path.dirname(twemojiPackage),
"dist",
"svg",
);
// get drop version
const dropVersion = getDropVersion();
// get git ref or supply during build
const commitHash =
process.env.BUILD_GIT_REF ??
execSync("git rev-parse --short HEAD").toString().trim();
console.log(`Drop ${dropVersion} #${commitHash}`);
2024-09-28 19:12:11 +10:00
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
2026-03-30 19:38:14 +11:00
extends: ["../libraries/base"],
2025-05-10 16:18:28 -04:00
// Module config from here down
2025-05-10 16:18:28 -04:00
modules: [
"vue3-carousel-nuxt",
"nuxt-security", // "@nuxt/image",
2025-05-10 16:18:28 -04:00
"@nuxt/fonts",
"@nuxt/eslint",
"@nuxtjs/i18n",
"@vueuse/nuxt",
2025-05-10 16:18:28 -04:00
],
2024-10-25 13:15:46 +11:00
// Nuxt-only config
telemetry: false,
2024-10-08 13:17:30 +11:00
compatibilityDate: "2024-04-03",
2025-04-07 19:57:00 -04:00
devtools: {
enabled: true,
telemetry: false,
timeline: {
2025-05-07 21:45:13 -04:00
// this seems to be the tracking issue, composables not registered
// https://github.com/nuxt/devtools/issues/662
2025-04-07 19:57:00 -04:00
enabled: false,
},
},
css: ["~/assets/tailwindcss.css", "~/assets/core.scss"],
2024-10-25 13:15:46 +11:00
sourcemap: {
server: true,
client: true,
},
experimental: {
buildCache: true,
viewTransition: false,
appManifest: false,
componentIslands: true,
},
2025-05-10 16:18:28 -04:00
// future: {
// compatibilityVersion: 4,
// },
vite: {
plugins: [
// eslint-disable-next-line @typescript-eslint/no-explicit-any
tailwindcss() as any,
],
},
runtimeConfig: {
gitRef: commitHash,
dropVersion: dropVersion,
},
2024-10-04 15:35:03 +10:00
app: {
head: {
2024-10-08 13:17:30 +11:00
link: [{ rel: "icon", href: "/favicon.ico" }],
},
},
routeRules: {
"/api/**": { cors: true },
// redirect old OIDC callback route
"/auth/callback/oidc": {
redirect: "/api/v1/auth/oidc/callback",
},
},
devServer: {
port: 4000,
},
nitro: {
minify: true,
compressPublicAssets: true,
experimental: {
websocket: true,
tasks: true,
openAPI: true,
},
openAPI: {
// tracking for dynamic openapi schema https://github.com/nitrojs/nitro/issues/2974
// create body from types: https://github.com/nitrojs/nitro/issues/3275
meta: {
title: "Drop",
description:
"Drop is an open-source, self-hosted game distribution platform, creating a Steam-like experience for DRM-free games.",
version: dropVersion,
},
},
scheduledTasks: {
"0 * * * *": ["dailyTasks"],
},
2025-05-07 22:13:22 -04:00
storage: {
appCache: {
driver: "lru-cache",
},
},
devStorage: {
appCache: {
// store cache on fs to handle dev server restarts
driver: "fs",
base: "./.data/appCache",
},
},
serverAssets: [
{
baseName: "twemoji",
// get path to twemoji svg assets
dir: twemojiAssetsPath,
},
],
},
2024-10-25 13:15:46 +11:00
typescript: {
2025-04-04 18:52:34 -04:00
typeCheck: true,
tsConfig: {
compilerOptions: {
verbatimModuleSyntax: false,
2025-04-07 19:55:33 -04:00
strictNullChecks: true,
exactOptionalPropertyTypes: true,
},
},
},
carousel: {
prefix: "Vue",
},
2024-10-25 13:15:46 +11:00
i18n: {
bundle: {
optimizeTranslationDirective: false,
},
defaultLocale: "en-us",
lazy: true,
strategy: "no_prefix",
experimental: {
localeDetector: "localeDetector.ts",
autoImportTranslationFunctions: true,
},
detectBrowserLanguage: {
useCookie: true,
cookieKey: "drop_i18n_redirected",
fallbackLocale: "en-us",
},
locales: [
{ code: "en-us", language: "en-us", name: "English", file: "en_us.json" },
{
code: "en-gb",
language: "en-gb",
name: "English (UK)",
file: "en_gb.json",
},
{
code: "en-au",
language: "en-au",
name: "English (Australia)",
file: "en_au.json",
},
{
code: "en-pirate",
language: "en-pirate",
name: "English (Pirate)",
file: "en_pirate.json",
},
{
code: "fr",
language: "fr",
name: "French",
file: "fr.json",
},
{
code: "de",
language: "de",
name: "German",
file: "de.json",
},
{
code: "it",
language: "it",
name: "Italian",
file: "it.json",
},
{
code: "es",
language: "es",
name: "Spanish",
file: "es.json",
},
{
code: "zh",
language: "zh",
name: "Chinese",
file: "zh.json",
},
{
code: "zh-tw",
language: "zh-tw",
name: "Chinese (Taiwan)",
file: "zh_tw.json",
},
],
},
security: {
headers: {
contentSecurityPolicy: {
2025-03-15 15:04:52 +11:00
"upgrade-insecure-requests": false,
"img-src": [
"'self'",
"data:",
"https://www.giantbomb.com",
"https://images.pcgamingwiki.com",
2025-03-12 14:19:33 -04:00
"https://images.igdb.com",
"https://*.steamstatic.com",
],
},
2025-03-14 20:31:00 +11:00
strictTransportSecurity: false,
},
rateLimiter: false,
xssValidator: false,
requestSizeLimiter: false,
},
});
/**
* Gets the drop version from the environment variable or package.json
* @returns {string} The drop version
*/
function getDropVersion(): string {
// get drop version from environment variable
if (process.env.BUILD_DROP_VERSION) {
return process.env.BUILD_DROP_VERSION;
}
// example nightly: "v0.3.0-nightly.2025.05.28"
const defaultVersion = "v0.0.0-alpha.0";
const packageJsonPath = fileURLToPath(import.meta.resolve("./package.json"));
Update Prisma to 6.11 (#133) * chore: update prisma to 6.11 more prisma future proofing due to experimental features * chore: update dependencies twemoji - new unicode update argon2 - bux fixes vue3-carousel - improve mobile experiance vue-tsc - more stable * fix: incorrect prisma version in docker Also remove default value for BUILD_DROP_VERSION, that is now handled in nuxt config * fix: no logging in prod * chore: optimize docker builds even more * fix: revert adoption of prisma driverAdapters see: https://github.com/prisma/prisma/issues/27486 * chore: optimize dockerignore some more * Fix `pino-pretty` not being included in build (#135) * Remove `pino` from frontend * Fix for downloads and removing of library source (#136) * fix: downloads and removing library source * fix: linting * Fix max file size of 4GB (update droplet) (#137) * Fix manual metadata import (#138) * chore(deps): bump vue-i18n from 10.0.7 to 10.0.8 (#140) Bumps [vue-i18n](https://github.com/intlify/vue-i18n/tree/HEAD/packages/vue-i18n) from 10.0.7 to 10.0.8. - [Release notes](https://github.com/intlify/vue-i18n/releases) - [Changelog](https://github.com/intlify/vue-i18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/intlify/vue-i18n/commits/v10.0.8/packages/vue-i18n) --- updated-dependencies: - dependency-name: vue-i18n dependency-version: 10.0.8 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump @intlify/core from 10.0.7 to 10.0.8 (#139) --- updated-dependencies: - dependency-name: "@intlify/core" dependency-version: 10.0.8 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Small fixes (#141) * fix: save task as Json rather than string * fix: pull objects before creating game in database * fix: strips relative dirs from version information * fix: #132 * fix: lint * fix: news object ids and small tweaks * fix: notification styling errors * fix: lint * fix: build issues by regenerating lockfile --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: DecDuck <declanahofmeyr@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-25 07:28:00 -04:00
if (!existsSync(packageJsonPath)) {
console.error("Could not find package.json, using default version.");
return defaultVersion;
}
// parse package.json
const raw = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
const packageJson = packageJsonSchema(raw);
if (packageJson instanceof type.errors) {
console.error("Failed to parse package.json", packageJson.summary);
return defaultVersion;
}
// ensure version starts with 'v'
if (packageJson.version.startsWith("v")) {
return packageJson.version;
}
return `v${packageJson.version}`;
}