// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  modules: ['@vueuse/nuxt', '@pinia/nuxt', '@nuxt/icon', '@nuxt/image', '@vant/nuxt'],
  compatibilityDate: '2025-07-15',
  // devtools: { enabled: true },
  css: ['~/assets/scss/main.scss'], // 全局样式文件
  plugins: ['~/plugins/index.js'],
  app: {
    head: {
      meta: [{ name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' }]
    }
  },
  postcss: {
    plugins: {
      autoprefixer: {
        overrideBrowserslist: ['last 15 versions']
      },
      'postcss-pxtorem': {
        rootValue: 37.5,
        unitPrecision: 4,
        propList: ['*'],
        selectorBlackList: [],
        replace: true,
        mediaQuery: false,
        minRemValue: 0,
        exclude: e => {
          if (e.includes('/app/pages/mobile/') || e.includes('/app/components/mobile/') || e.includes('/app/layouts/mobile.vue')) {
            return false
          } else {
            return true
          }
        }
      }
    }
  },
  icon: {
    localApiEndpoint: '/nuxt-icon'
  },
  image: {
    // format: ['avif', 'webp', 'png']
    format: ['webp', 'png']
  },
  nitro: {
    devProxy: {
      '/api': {
        target: 'http://localhost:8080', // 你的后端地址
        changeOrigin: true,
        prependPath: true
      }
    }
  },
  routeRules: {
    '/web/**': { appLayout: 'web' },
    '/mobile/**': { appLayout: 'mobile' }
  }
  // vite: {
  //   css: {
  //     preprocessorOptions: {
  //       scss: {
  //         additionalData: '@use "~/assets/_colors.scss" as *;'
  //       }
  //     }
  //   }
  // }
})