Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

4.6 KB
Raw Blame
import path from "node:path";
import createBundleAnalyzer from "@next/bundle-analyzer";
import type { NextConfig } from "next";

const withBundleAnalyzer = createBundleAnalyzer({
  enabled: process.env.ANALYZE === "true",
});

const appBaseUrl = process.env.NEXT_PUBLIC_APP_BASE_URL;

function createAppUrl(subpath: string) {
  const url = new URL(subpath, appBaseUrl);
  return url.href;
}

const nextConfig: NextConfig = {
  cacheComponents: true,
  partialPrefetching: true,
  allowedDevOrigins: [process.env.DEV_DOMAIN ?? "landing.rallly.localhost"],
  productionBrowserSourceMaps: true,
  // Serves /_next/static from a CDN-cached host to keep the immutable
  // bundles off Vercel's bandwidth bill. Unset outside production.
  assetPrefix: process.env.NEXT_PUBLIC_ASSET_PREFIX,
  // Loads chunks from that host as CORS requests instead of opaque no-cors
  // ones. Since the move, WebKit has kept broken cached copies of the opaque
  // chunks, which stops the page from hydrating. The asset host must send
  // Access-Control-Allow-Origin on every response, or no browser will run
  // the scripts.
  crossOrigin: process.env.NEXT_PUBLIC_ASSET_PREFIX ? "anonymous" : undefined,
  transpilePackages: [
    "@rallly/ui",
    "@rallly/tailwind-config",
    "@rallly/utils",
    "@rallly/posthog",
    "next-mdx-remote",
  ],
  webpack(config) {
    config.module.rules.push({
      test: /\.svg$/,
      issuer: /\.[jt]sx?$/,
      use: ["@svgr/webpack"],
    });

    return config;
  },
  images: {
    qualities: [100, 75],
    remotePatterns: [
      {
        protocol: "https",
        hostname: "d39ixtfgglw55o.cloudfront.net",
      },
    ],
  },
  turbopack: {
    root: path.join(__dirname, "../.."),
    rules: {
      "*.svg": {
        loaders: ["@svgr/webpack"],
        as: "*.js",
      },
    },
  },
  typescript: {
    ignoreBuildErrors: true,
  },
  async redirects() {
    return [
      // RFC 9116 legacy location
      {
        source: "/security.txt",
        destination: "/.well-known/security.txt",
        permanent: true,
      },
      {
        source: "/support",
        destination: "https://support.rallly.co",
        permanent: true,
      },
      // Ad-Blockers block the DigitalOcean logo, when we use our referral link
      {
        source: "/partners/digitalocean",
        destination: "https://m.do.co/c/f91efc9c9e50",
        permanent: true,
      },
      {
        source: "/p/:path*",
        destination: createAppUrl("/p/:path*"),
        permanent: true,
      },
      {
        source: "/invite/:path*",
        destination: createAppUrl("/invite/:path*"),
        permanent: true,
      },
      {
        source: "/e/:path*",
        destination: createAppUrl("/e/:path*"),
        permanent: true,
      },
      {
        source: "/admin/:path*",
        destination: createAppUrl("/admin/:path*"),
        permanent: true,
      },
      {
        source: "/profile",
        destination: createAppUrl("/profile"),
        permanent: true,
      },
      {
        source: "/login",
        destination: createAppUrl("/login"),
        permanent: true,
      },
      {
        source: "/new",
        destination: createAppUrl("/new"),
        permanent: true,
      },
      {
        source: "/register",
        destination: createAppUrl("/register"),
        permanent: true,
      },
      {
        source: "/buy-license/:product",
        destination: createAppUrl("/api/stripe/buy-license?product=:product"),
        permanent: false,
      },
      {
        source: "/S17JJrRWc",
        destination: "/",
        permanent: true,
      },
      {
        source: "/availability-poll",
        destination: "/free-scheduling-poll",
        permanent: true,
      },
      {
        source: "/meeting-poll",
        destination: "/free-scheduling-poll",
        permanent: true,
      },
      {
        source: "/:locale/availability-poll",
        destination: "/:locale/free-scheduling-poll",
        permanent: true,
      },
      {
        source: "/:locale/meeting-poll",
        destination: "/:locale/free-scheduling-poll",
        permanent: true,
      },
      {
        source: "/scheduling-for/executive-assistants",
        destination: "/scheduling-for/assistants",
        permanent: true,
      },
      {
        source: "/:locale/scheduling-for/executive-assistants",
        destination: "/:locale/scheduling-for/assistants",
        permanent: true,
      },
    ];
  },
};

// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
export default withBundleAnalyzer(nextConfig);