import grabDist from "./utils/grabDist";
import createMDX from "@next/mdx";
import { NextConfig } from "next";
import setupDb from "./utils/setup-db";
import debugLog from "./package-shared/utils/logging/debug-log";

setupDb();

const distDir = grabDist();

global.ERROR_CALLBACK = (title, error) => {
    debugLog({
        log: error.message,
        addTime: true,
        label: title,
        title: "Global Error Log",
    });
};

const nextConfig: NextConfig = {
    reactStrictMode: true,
    eslint: {
        ignoreDuringBuilds: true,
    },
    typescript: {
        ignoreBuildErrors: true,
    },
    pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
    distDir,
};

const withMDX = createMDX({
    // Add markdown plugins here, as desired
});

export default withMDX(nextConfig);
