/**
 * @type {import('next').NextConfig}
 */
import withSerwistInit from '@serwist/next';

const output = process.env.NODE_ENV === 'production' ? 'export' : 'standalone';

// Configure Serwist for service worker generation
const withSerwist = withSerwistInit({
  swSrc: 'src/sw.ts',
  swDest: 'public/sw.js',
  disable: process.env.NODE_ENV === 'development',
});

const nextConfig = {
  trailingSlash: true,
  distDir: 'build',
  output,
  basePath: '',
  devIndicators: {
    position: 'bottom-left',
  },
  typescript: {
    ignoreBuildErrors: false,
  },
  eslint: {
    ignoreDuringBuilds: false,
  },
  images: {
    unoptimized: true,
    remotePatterns: [
      {
        protocol: 'https',
        hostname: '**',
      },
    ],
    localPatterns: [
      {
        pathname: '/api/**',
      },
    ],
  },
};

export default withSerwist(nextConfig);