import tailwindcss from '@tailwindcss/vite'
import terser from '@rollup/plugin-terser'

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  ssr: false,
  modules: [
    '@nuxtjs/color-mode',
    'shadcn-nuxt',
    '@pinia/nuxt'
  ],
  app: {
    baseURL: process.env.APP_BASE_URL || '/',
    head: {
      title: 'Claude Code Web - Claude Code WebUI',
      viewport: 'width=device-width, initial-scale=1, viewport-fit=cover',
      link: [
        { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/icons/icon-32x32.png' },
        { rel: 'icon', type: 'image/png', sizes: '16x16', href: '/icons/icon-16x16.png' },
        { rel: 'manifest', href: '/manifest.webmanifest' },
        { rel: 'apple-touch-icon', href: '/apple-touch-icon.png' }
      ],
      meta: [
        { name: 'apple-mobile-web-app-capable', content: 'yes' },
        { name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
        { name: 'apple-mobile-web-app-title', content: 'Claude Code Web' },
        { name: 'mobile-web-app-capable', content: 'yes' },
        { name: 'theme-color', content: '#ffffff' },
        { name: 'msapplication-TileColor', content: '#ffffff' }
      ]
    }
  },
  colorMode: {
    classSuffix: ''
  },
  shadcn: {
    /**
     * Prefix for all the imported component
     */
    prefix: '',
    /**
     * Directory that the component lives in.
     * @default "./components/ui"
     */
    componentDir: './app/components/ui',
  },
  css: ['~/assets/css/main.css', '~/assets/css/simple-layout.css'],
  vite: {
    plugins: [
      tailwindcss(),
    ],
    server: {
      allowedHosts: true,
    },
    build: {
      minify: 'terser',
      terserOptions: {
        compress: {
          drop_console: true,
          drop_debugger: true,
          pure_funcs: ['console.log', 'console.info', 'console.debug', 'console.trace'],
        },
        mangle: true,
        format: {
          comments: false,
        },
      },
      cssMinify: true,
      cssCodeSplit: false,
      rollupOptions: {
        output: {
          manualChunks: undefined,
        },
      },
    },
  },
  nitro: {
    baseURL: process.env.APP_BASE_URL || '/',
    experimental: {
      wasm: true,
      websocket: true
    },
    // minify: true,
    // sourceMap: false,
    compressPublicAssets: {
      gzip: true,
      brotli: true,
    },
    rollupConfig: {
      output: {
        // compact: true,
        // generatedCode: {
        //   constBindings: true,
        // },
      },
      plugins: [
        terser({
          compress: {
            drop_console: true,
            drop_debugger: true,
          }
        }),
      ],
    },
  },
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true }
})


