import tailwindcss from "@tailwindcss/vite"; import { siteConfig } from "./shared/config/site"; /** Pages are server-rendered and cached; the cache is dropped by the API after content changes. */ const PAGE_CACHE_SECONDS = 60; export default defineNuxtConfig({ compatibilityDate: "2026-10-01", ssr: true, devtools: { enabled: false }, modules: ["@pinia/nuxt"], css: ["~/assets/css/main.css", "~/assets/css/antd-overrides.css"], alias: { "dayjs/plugin/advancedFormat": "dayjs/esm/plugin/advancedFormat/index.js", "dayjs/plugin/customParseFormat": "dayjs/esm/plugin/customParseFormat/index.js", "dayjs/plugin/localeData": "dayjs/esm/plugin/localeData/index.js", "dayjs/plugin/quarterOfYear": "dayjs/esm/plugin/quarterOfYear/index.js", "dayjs/plugin/weekOfYear": "dayjs/esm/plugin/weekOfYear/index.js", "dayjs/plugin/weekYear": "dayjs/esm/plugin/weekYear/index.js", "dayjs/plugin/weekday": "dayjs/esm/plugin/weekday/index.js", dayjs: "dayjs/esm/index.js", }, app: { head: { htmlAttrs: { lang: siteConfig.lang, dir: siteConfig.dir }, bodyAttrs: { class: "relative min-h-screen bg-bg font-sans text-ink antialiased", }, charset: "utf-8", viewport: "width=device-width, initial-scale=1", link: [ { rel: "preload", href: "/fonts/IRANSansWebFaNum.woff2", as: "font", type: "font/woff2", crossorigin: "", }, { rel: "preload", href: "/fonts/IRANSansWebFaNum_Bold.woff2", as: "font", type: "font/woff2", crossorigin: "", }, { rel: "icon", type: "image/svg+xml", href: siteConfig.favicon }, { rel: "manifest", href: "/manifest.webmanifest" }, ], }, }, // overridable at runtime with NUXT_API_INTERNAL_URL, NUXT_REVALIDATE_SECRET, NUXT_PUBLIC_SITE_URL ... runtimeConfig: { /** API base URL used during server-side rendering (inside Docker: http://api:4000/api) */ apiInternalUrl: "http://localhost:4000/api", /** shared secret the API sends to /_internal/revalidate */ revalidateSecret: "", public: { /** API base URL used by the browser (same origin, routed by nginx / the dev proxy) */ apiBase: "/api", siteUrl: siteConfig.url, }, }, // production only: in dev a cached page would serve stale HTML after code edits (hydration errors) $production: { routeRules: { "/": { swr: PAGE_CACHE_SECONDS }, "/categories/**": { swr: PAGE_CACHE_SECONDS }, "/products/**": { swr: PAGE_CACHE_SECONDS }, "/sitemap.xml": { swr: 3600 }, "/manifest.webmanifest": { swr: 3600 }, }, }, nitro: { // in production nginx routes these paths; in dev the Nuxt server forwards them devProxy: { "/api": { target: "http://localhost:4000/api", changeOrigin: true }, "/media": { target: "http://localhost:9000/imen-media", changeOrigin: true }, }, }, build: { transpile: ["ant-design-vue", "@ant-design/icons-vue", "@ctrl/tinycolor", "dayjs"], }, vite: { plugins: [tailwindcss()], optimizeDeps: { include: [ "ant-design-vue", "@ant-design/icons-vue", "@ctrl/tinycolor", "dayjs", "dayjs/plugin/advancedFormat", "dayjs/plugin/customParseFormat", "dayjs/plugin/localeData", "dayjs/plugin/quarterOfYear", "dayjs/plugin/weekOfYear", "dayjs/plugin/weekYear", "dayjs/plugin/weekday", ], }, ssr: { noExternal: ["ant-design-vue", "@ant-design/icons-vue", "@ctrl/tinycolor", "dayjs"] }, }, typescript: { strict: true }, });