diff --git a/env.mjs b/env.mjs new file mode 100644 index 0000000..a3adf0e --- /dev/null +++ b/env.mjs @@ -0,0 +1,15 @@ +import { createEnv } from "@t3-oss/env-nextjs" +import { z } from "zod" + +export const env = createEnv({ + server: { + ANALYZE: z + .enum(["true", "false"]) + .optional() + .transform((value) => value === "true"), + }, + client: {}, + runtimeEnv: { + ANALYZE: process.env.ANALYZE, + }, +}) diff --git a/next.config.mjs b/next.config.mjs index 55f6899..72864c7 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,10 +1,11 @@ import withBundleAnalyzer from "@next/bundle-analyzer" import withPlugins from "next-compose-plugins" +import { env } from "./env.mjs" /** * @type {import('next').NextConfig} */ -const config = withPlugins([[withBundleAnalyzer({ enabled: process.env.ANALYZE === "true" })]], { +const config = withPlugins([[withBundleAnalyzer({ enabled: env.ANALYZE })]], { reactStrictMode: true, experimental: { instrumentationHook: true }, rewrites() {