One Calendar is a privacy-first calendar web app built with Next.js. It has modern security features, including e2ee, password-protected sharing, and self-destructing share links 馃搮 calendar.xyehr.cn
at main 90 lines 1.8 kB view raw
1import { execSync } from "node:child_process"; 2import { readFileSync } from "node:fs"; 3 4let userConfig = undefined; 5try { 6 userConfig = await import("./next.config"); 7} catch (e) {} 8 9const packageJson = JSON.parse( 10 readFileSync(new URL("./package.json", import.meta.url), "utf8"), 11); 12 13const getGitCommit = () => { 14 try { 15 return execSync("git rev-parse --short HEAD", { encoding: "utf8" }).trim(); 16 } catch { 17 return "unknown"; 18 } 19}; 20 21const nextConfig = { 22 typescript: { 23 ignoreBuildErrors: true, 24 }, 25 images: { 26 formats: ["image/avif", "image/webp"], 27 minimumCacheTTL: 60 * 60 * 24, 28 }, 29 env: { 30 NEXT_PUBLIC_APP_VERSION: packageJson.version, 31 NEXT_PUBLIC_GIT_COMMIT: getGitCommit(), 32 NEXT_PUBLIC_BUILD_TIME: new Date().toISOString(), 33 }, 34 35 experimental: { 36 optimizePackageImports: [ 37 "lucide-react", 38 "date-fns", 39 "@radix-ui/react-icons", 40 "recharts", 41 ], 42 }, 43 44 async headers() { 45 return [ 46 { 47 source: "/_next/static/:path*", 48 headers: [ 49 { 50 key: "Cache-Control", 51 value: "public, max-age=31536000, immutable", 52 }, 53 ], 54 }, 55 { 56 source: "/app", 57 headers: [ 58 { 59 key: "Cache-Control", 60 value: "public, s-maxage=120, stale-while-revalidate=600", 61 }, 62 ], 63 }, 64 ]; 65 }, 66}; 67 68mergeConfig(nextConfig, userConfig); 69 70function mergeConfig(nextConfig, userConfig) { 71 if (!userConfig) { 72 return; 73 } 74 75 for (const key in userConfig) { 76 if ( 77 typeof nextConfig[key] === "object" && 78 !Array.isArray(nextConfig[key]) 79 ) { 80 nextConfig[key] = { 81 ...nextConfig[key], 82 ...userConfig[key], 83 }; 84 } else { 85 nextConfig[key] = userConfig[key]; 86 } 87 } 88} 89 90export default nextConfig;