import type { NextConfig } from "next";

const withPWA = require("@ducanh2912/next-pwa").default({
  dest: "public",
  register: true,
  skipWaiting: true,
  disable: process.env.NODE_ENV === "development",
});

const nextConfig: NextConfig = {
  // Enable standalone output for Docker
  output: 'standalone',

  // Webpack config (needed for PWA plugin)
  webpack: (config, { isServer }) => {
    // Fixes npm packages that depend on `fs` module
    if (!isServer) {
      config.resolve.fallback = {
        ...config.resolve.fallback,
        fs: false,
      };
    }
    return config;
  },

  // Optimize for production
  reactStrictMode: true,

  // Image optimization
  images: {
    unoptimized: true, // Required for standalone
  },
};

export default withPWA(nextConfig);
