next/nuxt.config.ts

156 lines
3.3 KiB
TypeScript
Raw Normal View History

2023-09-23 15:58:51 -04:00
// https://nuxt.com/docs/api/configuration/nuxt-config
import { IUser } from "@models/user";
2024-03-21 18:43:29 -04:00
import { render } from "vue";
import { rc } from "./lib/server/constants";
2024-03-21 18:43:29 -04:00
import { defineNuxtConfig } from "nuxt/config";
import { fileURLToPath } from "url";
const cac = {
isr: true,
headersOnly: true,
cache: {
headersOnly: true,
2023-12-06 21:58:35 -05:00
varies: ["Content-Length", "Cookie"],
maxAge: 60,
},
swr: false,
};
2023-09-23 15:58:51 -04:00
export default defineNuxtConfig({
experimental: {
watcher: "chokidar-granular",
treeshakeClientOnly: true,
},
devtools: { enabled: false },
modules: [
"vue-recaptcha/nuxt",
"@ant-design-vue/nuxt",
"@sidebase/nuxt-auth",
"@pinia/nuxt",
"@vueuse/nuxt",
2024-03-21 18:43:29 -04:00
"@nuxt/test-utils/module",
// "@nuxtjs/i18n",
],
// i18n: {
// vueI18n: `./i18n.config.ts`,
// },
antd: {
extractStyle: true,
},
css: ["public/fonts.css", "public/css/all.css"],
auth: {
baseURL: "/api/auth",
provider: {
2024-11-14 17:49:42 -05:00
type: "local",
pages: {
login: "/auth/login",
},
token: {
signInResponseTokenPointer: "/token/access",
type: "Bearer",
headerName: "Authorization",
maxAgeInSeconds: 15 * 60,
cookieName: "rockfic_cookie",
},
2024-11-14 17:49:42 -05:00
2023-12-09 17:49:09 -05:00
// @ts-ignore
2023-12-06 21:58:35 -05:00
sessionDataType: {} as IUser,
endpoints: {
signUp: { path: "/register", method: "post" },
signOut: { path: "/logout", method: "post" },
getSession: {
path: "/session",
method: "get",
},
2024-11-14 17:49:42 -05:00
},
refresh: {
isEnabled: true,
endpoint: { path: "/refresh", method: "post" },
token: {
signInResponseRefreshTokenPointer: "/token/refresh",
cookieName: "rockfic.refresh",
maxAgeInSeconds: 1800,
sameSiteAttribute: "lax",
secureCookieAttribute: false,
cookieDomain: process.env.NODE_ENV == "staging" ? "next.rockfic.com" : process.env.NODE_ENV == "production" ? "www.rockfic.com" : "localhost:3000",
httpOnlyCookieAttribute: false,
},
},
},
globalAppMiddleware: false,
//@ts-ignore
session: {
enableRefreshPeriodically: 60 * 60 * 2 * 1000,
enableRefreshOnWindowFocus: false,
},
},
2024-03-21 18:43:29 -04:00
vite: {
esbuild: {
logLimit: 0,
logLevel: "debug",
target: "es2020",
2024-03-21 18:43:29 -04:00
},
logLevel: "info",
},
nitro: {
esbuild: {
options: {
minify: true,
2024-03-21 18:43:29 -04:00
// loader: "default",
logLevel: "verbose",
// sourceMap: "inline",
target: "es2020",
},
},
preset: process.env.NODE_ENV == "production" ? "bun" : "node-server",
},
routeRules: {
"/": cac,
"/api/**": { cors: true },
2023-12-06 21:58:35 -05:00
"/band/**": cac,
"/authors": cac,
"/story/**": {
swr: true,
isr: true,
cache: {
maxAge: 1800,
2023-12-06 21:58:35 -05:00
headersOnly: true,
varies: ["Cookie", "Set-Cookie"],
},
},
},
2024-03-21 18:43:29 -04:00
alias: {
"@models": fileURLToPath(new URL("./models", import.meta.url)),
"@client": fileURLToPath(new URL("./lib/client", import.meta.url)),
"@server": fileURLToPath(new URL("./lib/server", import.meta.url)),
"@functions": fileURLToPath(new URL("./lib/functions.ts", import.meta.url)),
"@dbconfig": fileURLToPath(new URL("./lib/dbconfig.ts", import.meta.url)),
2024-03-21 18:43:29 -04:00
"@test": fileURLToPath(new URL("./lib/testing/", import.meta.url)),
},
sourcemap: {
server: true,
client: true,
},
2024-03-21 18:43:29 -04:00
runtimeConfig: rc,
typescript: {
tsConfig: {
exclude: ["./.nuxt/types/auth.d.ts"],
},
},
imports: {
autoImport: true,
dirsScanOptions: {
types: true,
},
},
compatibilityDate: "2024-11-07",
});