refactor(nuxt): add cache, treeshaking and sourcemap capabilities to nuxt config
This commit is contained in:
parent
b1c94ab0ae
commit
1b75c199a4
@ -4,6 +4,17 @@ import { defineNuxtModule } from "@nuxt/kit";
|
||||
// import speedkitHydrate from "nuxt-speedkit/dist/runtime/hydrate.mjs";
|
||||
|
||||
export type SessionData = IUser;
|
||||
const cac = {
|
||||
isr: true,
|
||||
headersOnly: true,
|
||||
cache: {
|
||||
headersOnly: true,
|
||||
// integrity: "",
|
||||
// varies: ["Content-Length"],
|
||||
maxAge: 60,
|
||||
},
|
||||
swr: false,
|
||||
};
|
||||
const ct =
|
||||
<T>() =>
|
||||
<U extends T>(u: U) =>
|
||||
@ -12,7 +23,7 @@ export default defineNuxtConfig({
|
||||
experimental: {
|
||||
watcher: "chokidar-granular",
|
||||
// noScripts: true,
|
||||
treeshakeClientOnly: false,
|
||||
treeshakeClientOnly: true,
|
||||
},
|
||||
devtools: { enabled: false },
|
||||
modules: [
|
||||
@ -21,23 +32,18 @@ export default defineNuxtConfig({
|
||||
"@sidebase/nuxt-auth",
|
||||
"@pinia/nuxt",
|
||||
"@vueuse/nuxt",
|
||||
// defineNuxtModule({
|
||||
// async setup(options, nuxt) {
|
||||
// nuxt.hook("components:extend", (components) => {
|
||||
// // console.log(components);
|
||||
// // components = components.map((a) => {
|
||||
// // return speedkitHydrate(() => import(a.filePath));
|
||||
// // });
|
||||
// });
|
||||
// },
|
||||
// }),
|
||||
// "nuxt-speedkit",
|
||||
"nuxt-speedkit",
|
||||
],
|
||||
// speedkit: {
|
||||
// disableNuxtFontaine: true,
|
||||
// },
|
||||
speedkit: {
|
||||
disableNuxtFontaine: true,
|
||||
lazyOffset: {
|
||||
component: "0%",
|
||||
asset: "0%",
|
||||
},
|
||||
},
|
||||
css: ["~/public/fonts.css", "~/public/css/all.css"],
|
||||
auth: {
|
||||
baseURL: "/api/auth",
|
||||
provider: {
|
||||
type: "local",
|
||||
pages: {
|
||||
@ -47,27 +53,51 @@ export default defineNuxtConfig({
|
||||
signInResponseTokenPointer: "/token",
|
||||
type: "Bearer",
|
||||
headerName: "Authorization",
|
||||
maxAgeInSeconds: 168 * 24 * 60 * 60,
|
||||
sameSiteAttribute: "lax",
|
||||
maxAgeInSeconds: 14 * 24 * 60 * 60,
|
||||
// sameSiteAttribute: ,
|
||||
},
|
||||
sessionDataType: {} as { [Property in keyof IUser]: string },
|
||||
endpoints: {
|
||||
signUp: { path: "/register", method: "post" },
|
||||
signOut: { path: "/logout", method: "post" },
|
||||
getSession: {
|
||||
path: "/session",
|
||||
method: "get",
|
||||
},
|
||||
},
|
||||
globalAppMiddleware: {
|
||||
isEnabled: false,
|
||||
},
|
||||
globalAppMiddleware: false,
|
||||
|
||||
//@ts-ignore
|
||||
session: {
|
||||
enableRefreshPeriodically: 60 * 60 * 2 * 1000,
|
||||
enableRefreshOnWindowFocus: false,
|
||||
},
|
||||
},
|
||||
nitro: {
|
||||
esbuild: {
|
||||
options: {
|
||||
minify: true,
|
||||
// sourceMap: false,
|
||||
sourceMap: "inline",
|
||||
},
|
||||
},
|
||||
preset: "node",
|
||||
},
|
||||
routeRules: {
|
||||
"/": cac,
|
||||
"/api/**": { cors: true },
|
||||
"/bands/**": cac,
|
||||
"/authors": cac,
|
||||
"/story/**": {
|
||||
swr: true,
|
||||
isr: true,
|
||||
cache: {
|
||||
maxAge: 1800,
|
||||
},
|
||||
},
|
||||
// "/authors": { swr: 0 },
|
||||
// "/bands": { swr: 0 },
|
||||
},
|
||||
|
||||
// routeRules: {
|
||||
// "/**": {
|
||||
// cache: {
|
||||
@ -78,6 +108,10 @@ export default defineNuxtConfig({
|
||||
// },
|
||||
// },
|
||||
// ssr: false,
|
||||
sourcemap: {
|
||||
server: true,
|
||||
client: true,
|
||||
},
|
||||
runtimeConfig: {
|
||||
captcha: {
|
||||
secret: process.env.CAPTCHASECRET,
|
||||
@ -93,6 +127,11 @@ export default defineNuxtConfig({
|
||||
recaptcha: {
|
||||
v2SiteKey: process.env.CAPTCHAKEY,
|
||||
},
|
||||
auth: {
|
||||
computed: {
|
||||
origin: "127.0.0.1",
|
||||
},
|
||||
},
|
||||
// apiBase: "/api"
|
||||
},
|
||||
nodebb: {
|
||||
|
Loading…
Reference in New Issue
Block a user