You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.4 KiB
94 lines
2.4 KiB
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
import { existsSync } from "node:fs";
|
|
import { createRequire } from "node:module";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import {
|
|
CLOUD_PROBE_PATH_PREFIXES,
|
|
CLOUD_PROBE_PATHS,
|
|
} from "./server/constants/cloud-probes";
|
|
|
|
const configDir = dirname(fileURLToPath(import.meta.url));
|
|
const require = createRequire(import.meta.url);
|
|
|
|
const probeCacheControl =
|
|
"no-store, no-cache, must-revalidate, proxy-revalidate";
|
|
|
|
function resolveNuxtNitroErrorHandler(): string {
|
|
const path = join(
|
|
dirname(require.resolve("nuxt/package.json")),
|
|
"..",
|
|
"@nuxt",
|
|
"nitro-server",
|
|
"dist",
|
|
"runtime",
|
|
"handlers",
|
|
"error.mjs",
|
|
);
|
|
if (!existsSync(path)) {
|
|
throw new Error(`Missing Nuxt Nitro error handler: ${path}`);
|
|
}
|
|
return path;
|
|
}
|
|
|
|
export default defineNuxtConfig({
|
|
compatibilityDate: '2025-07-15',
|
|
/** 部署时设置 `NUXT_PUBLIC_SITE_URL`(如 https://blog.example.com)可自动覆盖;用于媒体绝对链接与引用同步。 */
|
|
runtimeConfig: {
|
|
public: {
|
|
siteUrl: '',
|
|
},
|
|
},
|
|
modules: ['@nuxt/ui'],
|
|
css: ['~/assets/css/main.css'],
|
|
ui: {
|
|
fonts: false
|
|
},
|
|
devtools: { enabled: true },
|
|
/** 探针路径与 `server/middleware/00.cloud-probe.ts` 一致:禁止 CDN/LB 长期缓存探测响应 */
|
|
routeRules: {
|
|
...Object.fromEntries(
|
|
CLOUD_PROBE_PATHS.map((path) => [
|
|
path,
|
|
{ headers: { "cache-control": probeCacheControl } },
|
|
]),
|
|
),
|
|
...Object.fromEntries(
|
|
CLOUD_PROBE_PATH_PREFIXES.flatMap((prefix) => [
|
|
[`${prefix}/**`, { headers: { "cache-control": probeCacheControl } }],
|
|
[prefix, { headers: { "cache-control": probeCacheControl } }],
|
|
]),
|
|
),
|
|
},
|
|
typescript: {
|
|
tsConfig: {
|
|
compilerOptions: {
|
|
types: ['bun-types'],
|
|
}
|
|
}
|
|
},
|
|
nitro: {
|
|
errorHandler: [join(configDir, "server/error-json.ts"), resolveNuxtNitroErrorHandler()],
|
|
experimental: {
|
|
tasks: true,
|
|
},
|
|
scheduledTasks: {
|
|
'5 * * * *': ['media:orphan-sweep'],
|
|
},
|
|
typescript: {
|
|
tsConfig: {
|
|
compilerOptions: {
|
|
types: ['bun-types'],
|
|
resolvePackageJsonExports: true,
|
|
resolvePackageJsonImports: true,
|
|
baseUrl: './',
|
|
paths: {
|
|
'drizzle-pkg': ['./packages/drizzle-pkg/lib'],
|
|
'logger': ['./packages/logger/lib']
|
|
},
|
|
}
|
|
},
|
|
}
|
|
},
|
|
})
|
|
|