const isDevelopment = process.env.NODE_ENV !== "production";
const rewritesConfig = isDevelopment
  ? [
      {
        source: "/api/:path*",
        destination: "https://tssearch.ceymox.net/:path*",
      },
    ]
  : [
      {
        source: "/api/:path*",
        destination: "https://tssearch.ceymox.net/:path*",
      },
    ];

module.exports = {
  reactStrictMode: true,
  images: {
    domains: ["tssearch.ceymox.net"],
  },
  webpack: (config, { isServer }) => {
    config.resolve.extensions.push(".ts", ".tsx", ".js", ".json");
    config.module.rules.push({
      test: /\.(ts|tsx)$/,
      exclude: /node_modules/,
      use: [
        {
          loader: 'ts-loader',
        },
      ],
    });

    // config.module.rules.push({
    //   test: /\.(scss|sass)$/,
    //   use: [
    //     "style-loader",
    //     "css-loader",
    //     "sass-loader",
    //   ],
    // });

    return config;
  },
  async rewrites() {
    return rewritesConfig;
  },
};
