-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.ts
More file actions
73 lines (68 loc) · 2.18 KB
/
next.config.ts
File metadata and controls
73 lines (68 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { withPostHogConfig } from "@posthog/nextjs-config";
import type { NextConfig } from "next";
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "next/constants.js";
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
import { env } from "@/env.config";
let nextConfig: NextConfig = {
typedRoutes: true,
reactCompiler: true,
experimental: {
turbopackFileSystemCacheForDev: true,
},
images: {
deviceSizes: [384, 640, 768, 1024, 1280, 1536, 1920],
formats: ["image/webp"],
// One month
minimumCacheTTL: 60 * 60 * 24 * 30,
},
logging: {
fetches: {
fullUrl: true,
},
},
pageExtensions: ["js", "jsx", "ts", "tsx"],
reactStrictMode: true,
rewrites() {
return [
{
destination: "https://us-assets.i.posthog.com/static/:path*",
source: "/ingest/static/:path*",
},
{
destination: "https://us.i.posthog.com/:path*",
source: "/ingest/:path*",
},
{
destination: "https://us.i.posthog.com/decide",
source: "/ingest/decide",
},
];
},
// This is required to support PostHog trailing slash API requests
skipTrailingSlashRedirect: true,
staticPageGenerationTimeout: 300,
};
if (env.POSTHOG_API_KEY && env.POSTHOG_ENV_ID) {
nextConfig = withPostHogConfig(nextConfig, {
personalApiKey: env.POSTHOG_API_KEY, // Personal API Key
envId: env.POSTHOG_ENV_ID, // Environment ID
host: env.NEXT_PUBLIC_POSTHOG_HOST, // (optional), defaults to https://us.posthog.com
sourcemaps: {
enabled: true, // Enable sourcemaps generation and upload, default to true on production builds
deleteAfterUpload: false, // Delete sourcemaps after upload, defaults to true
},
});
}
// biome-ignore lint/style/noDefaultExport: Config file
export default (phase: string) => {
const isDev = phase === PHASE_DEVELOPMENT_SERVER;
const isBuild = phase === PHASE_PRODUCTION_BUILD;
if (!process.env.VELITE_STARTED && (isDev || isBuild)) {
process.env.VELITE_STARTED = "1";
import("velite").then((m) => m.build({ watch: isDev, clean: !isDev }));
}
return nextConfig;
};