2022-12-16 21:57:01 +08:00
import path from "node:path" ;
2023-01-26 03:49:23 +08:00
import VueI18n from "@intlify/unplugin-vue-i18n" ;
2022-12-16 21:57:01 +08:00
import IconsResolver from "unplugin-icons/resolver" ;
import Icons from "unplugin-icons/vite" ;
import Components from "unplugin-vue-components/vite" ;
2023-01-09 01:11:39 +08:00
import { ProxyOptions } from "@nuxt-alt/proxy" ;
2023-01-30 07:23:28 +08:00
import { defineNuxtConfig } from "nuxt/config" ;
2022-12-16 21:57:01 +08:00
import prettier from "./src/lib/plugins/prettier" ;
2023-01-11 03:59:57 +08:00
import unocss from "./src/lib/config/unocss.config" ;
2022-12-16 21:57:01 +08:00
const backendHost = process . env . BACKEND_HOST || "http://localhost:8080" ;
const authHost = process . env . AUTH_HOST || "http://localhost:3001" ;
2022-12-31 02:43:48 +08:00
const local = true ; // set to false if backendData should be fetched from staging. You might need to hard reload (Ctrl+F5) the next page you're on when changing this value
2022-12-24 22:12:39 +08:00
const backendDataHost = process . env . BACKEND_DATA_HOST || ( local ? "http://localhost:8080" : "https://hangar.papermc.dev" ) ;
2023-01-09 01:47:23 +08:00
const allowIndexing = process . env . HANGAR_ALLOW_INDEXING || "true" ;
2022-12-16 21:57:01 +08:00
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig ( {
imports : {
autoImport : false ,
} ,
srcDir : "src" ,
runtimeConfig : {
authHost ,
backendHost ,
2023-01-09 01:47:23 +08:00
public : {
allowIndexing ,
} ,
2022-12-16 21:57:01 +08:00
} ,
2023-01-11 03:59:57 +08:00
unocss ,
2022-12-23 22:44:16 +08:00
module s : [
2023-01-11 03:59:57 +08:00
"@unocss/nuxt" ,
2022-12-23 22:44:16 +08:00
"@pinia/nuxt" ,
2023-01-09 01:11:39 +08:00
"@nuxt-alt/proxy" ,
2022-12-23 22:44:16 +08:00
"unplugin-icons/nuxt" ,
2023-01-30 07:23:28 +08:00
// "@unlighthouse/nuxt",
2022-12-23 22:44:16 +08:00
[
"./src/module/backendData" ,
{
serverUrl : backendDataHost ,
} ,
] ,
] ,
2022-12-16 21:57:01 +08:00
vite : {
plugins : [
// https://github.com/antfu/unplugin-vue-components
Components ( {
// we don't want to import components, just icons
dirs : [ "none" ] ,
// auto import icons
resolvers : [
// https://github.com/antfu/vite-plugin-icons
IconsResolver ( {
componentPrefix : "icon" ,
enabledCollections : [ "mdi" ] ,
} ) ,
] ,
dts : "types/generated/icons.d.ts" ,
} ) ,
// https://github.com/antfu/unplugin-icons
Icons ( {
autoInstall : true ,
} ) ,
// https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
2023-01-26 03:49:23 +08:00
VueI18n . vite ( {
2022-12-16 21:57:01 +08:00
include : [ path . resolve ( __dirname , "src/locales/*.json" ) ] ,
} ) ,
// TODO fix this
// EslintPlugin({
// fix: true,
// }),
prettier ( ) ,
] ,
ssr : {
// Workaround until they support native ESM
noExternal : [ "vue3-popper" ] ,
} ,
} ,
experimental : {
writeEarlyHints : false ,
} ,
2022-12-21 01:47:00 +08:00
typescript : {
// typeCheck: "build", // TODO enable typechecking on build
} ,
2022-12-22 22:57:29 +08:00
nitro : {
2023-01-06 04:20:59 +08:00
preset : "node-cluster" ,
2022-12-22 22:57:29 +08:00
compressPublicAssets : true ,
} ,
2023-01-08 22:29:51 +08:00
sourcemap : {
server : true ,
client : true ,
} ,
2022-12-23 01:56:27 +08:00
vue : {
compilerOptions : {
isCustomElement : ( tag ) = > [ "lottie-player" ] . includes ( tag ) ,
} ,
} ,
2022-12-16 21:57:01 +08:00
proxy : {
enableProxy : true ,
proxies : {
2023-01-06 03:27:45 +08:00
// for performance, these should be mirrored in ingress
2022-12-16 21:57:01 +08:00
"/api/" : defineProxyBackend ( ) ,
"/signup" : defineProxyBackend ( ) ,
"/login" : defineProxyBackend ( ) ,
"/logout" : defineProxyBackend ( ) ,
"/handle-logout" : defineProxyBackend ( ) ,
"/refresh" : defineProxyBackend ( ) ,
"/invalidate" : defineProxyBackend ( ) ,
2022-12-28 08:44:06 +08:00
"/v3/api-docs" : defineProxyBackend ( ) ,
2022-12-16 21:57:01 +08:00
"/robots.txt" : defineProxyBackend ( ) ,
"/sitemap.xml" : defineProxyBackend ( ) ,
"/global-sitemap.xml" : defineProxyBackend ( ) ,
2023-01-09 01:11:39 +08:00
"^/.*/sitemap.xml" : defineProxyBackend ( ) ,
2022-12-16 21:57:01 +08:00
"/statusz" : defineProxyBackend ( ) ,
// auth
"/avatar" : defineProxyAuth ( ) ,
"/oauth/logout" : defineProxyAuth ( ) ,
} ,
} ,
2022-12-22 23:33:45 +08:00
// cache statics for a year
routeRules : {
"/_nuxt/**" : { headers : { "Cache-Control" : "max-age=31536000, immutable" } } ,
"/**/*.js" : { headers : { "Cache-Control" : "max-age=31536000, immutable" } } ,
"/**/*.mjs" : { headers : { "Cache-Control" : "max-age=31536000, immutable" } } ,
"/**/*.css" : { headers : { "Cache-Control" : "max-age=31536000, immutable" } } ,
"/**/*.json" : { headers : { "Cache-Control" : "max-age=31536000, immutable" } } ,
"/**/*.xml" : { headers : { "Cache-Control" : "max-age=31536000, immutable" } } ,
"/**/*.svg" : { headers : { "Cache-Control" : "max-age=31536000, immutable" } } ,
} ,
2022-12-16 21:57:01 +08:00
} ) ;
function defineProxyAuth ( ) : ProxyOptions {
return {
configure : ( proxy , options ) = > {
options . target = process . env . AUTH_HOST || process . env . NITRO_AUTH_HOST || "http://localhost:3001" ;
} ,
changeOrigin : true ,
} ;
}
function defineProxyBackend ( ) : ProxyOptions {
return {
configure : ( proxy , options ) = > {
options . target = process . env . BACKEND_HOST || process . env . NITRO_BACKEND_HOST || "http://localhost:8080" ;
} ,
changeOrigin : true ,
} ;
}