import withPWA from 'next-pwa';
import { withSentryConfig } from '@sentry/nextjs';
import withPzConfig from '@akinon/next/with-pz-config.js';

/** @type {import('next').NextConfig} */
const nextConfig = {
  // Your Next.js config to override defaults
  rewrites: async () => {
    return [
      {
        source: '/:pz/sitemap.xml',
        destination: '/:pz/xml-sitemap'
      },
      {
        source: '/:pz/sitemap/:node',
        destination: '/:pz/xml-sitemap/:node'
      }
    ];
  }
};

const withPwaConfig = withPWA({
  dest: 'public',
  disable: process.env.NODE_ENV === 'development'
});

const sentryConfig = {
  silent: true,
  dryRun: !process.env.SENTRY_DSN,
  org: 'akinon'
  // project: 'enter_your_project_name_here',
  // authToken: 'enter_your_auth_token_here'
};

const enhancedConfig = withPzConfig(nextConfig);

export default withSentryConfig(withPwaConfig(enhancedConfig), sentryConfig);
