import type { NextConfig } from 'next';
import createNextIntlPlugin from 'next-intl/plugin';

import path from 'path';

const nextConfig: NextConfig = {
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'azopus.hu',
        pathname: '/**',
      },
      {
        protocol: 'http',
        hostname: 'test.azopus.hu',
        pathname: '/**',
      },
      {
        protocol: 'https',
        hostname: 'test.azopus.hu',
        pathname: '/**',
      },
    ],
    minimumCacheTTL: 60 * 60 * 24 * 7,
  },
  webpack: (config) => {
    config.resolve = {
      ...(config.resolve || {}),
      alias: {
        ...(config.resolve?.alias || {}),
        '@': path.resolve(__dirname, 'src'),
      },
    };
    return config;
  },
  // Enable source maps in test environment
  ...(process.env.NEXT_PUBLIC_ENV === 'test' && {
    productionBrowserSourceMaps: true,
  }),
};

const withNextIntl = createNextIntlPlugin();

export default withNextIntl(nextConfig);
