/** @type {import('next').NextConfig} */
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const nextConfig = {
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "portal.chatknot.com",
      },
    ], // Existing image domain config
  },
  turbopack: {
    rules: {
      "**/*.mp3": {
        loaders: [
          {
            loader: "file-loader",
            options: {
              name: "[name].[ext]",
              publicPath: "/sounds/",
              emitFile: false,
            },
          },
        ],
        as: "*.js",
      },
      "**/*.wav": {
        loaders: [
          {
            loader: "file-loader",
            options: {
              name: "[name].[ext]",
              publicPath: "/sounds/",
              emitFile: false,
            },
          },
        ],
        as: "*.js",
      },
    },
  },
  // Disable React strict mode if needed
  reactStrictMode: false,

  webpack: (config) => {
    // Add rule to handle audio files
    config.module.rules.push({
      test: /\.(mp3|wav|ogg)$/, // Add file extensions you want to support
      type: "asset/resource",
      generator: {
        filename: "static/sounds/[name].[hash][ext]",
      },
    });

    return config;
  },
};

export default nextConfig;
