import viteCompression from 'vite-plugin-compression';

// 筛选接口地址
let filterApi = 'http://156.247.9.93:9501/';
let loginApi = 'http://156.247.9.93:8001/';
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  // plugins: [],
  modules: ['nuxt-svgo', '@nuxtjs-alt/proxy'],
  proxy: {
    enableProxy: true,
    proxies: {
      '/score': {
        target: filterApi,
        changeOrigin: true,
      },
      '/v1': {
        target: filterApi,
        changeOrigin: true,
      },
      '/search': {
        target: filterApi,
        changeOrigin: true,
      },
      '/favorites': {
        target: filterApi,
        changeOrigin: true,
      },
      //api-ip是另外滴
      '/api': {
        target: loginApi,
        changeOrigin: true,
      },
      '/video': {
        target: 'http://192.168.1.19:5000',
        changeOrigin: true,
      },
    },
  },
  experimental: {
    writeEarlyHints: false,
  },
  //   env: {
  //     NODE_ENV: process.env.NODE_ENV,
  //   },
  vite: {
    plugins: [viteCompression()],
    envDir: '~/env',
    build: {
      minify: 'terser', // 混淆器，terser构建后文件体积更小
      cssCodeSplit: true, // 如果设置为false，整个项目中的所有 CSS 将被提取到一个 CSS 文件中
      terserOptions: {
        compress: {
          //生产环境时移除console
          drop_console: true,
          // drop_debugger: true,
        },
        output: {
          // 去掉注释内容
          comments: true,
        },
      },
      rollupOptions: {
        output: {
          manualChunks: {
            'tdesign-vue-next': ['tdesign-vue-next'],
          },
        },
      },
    },
  },
  build: {
    // extractCSS: true,
    // vendor-已被弃用
    // 第三方插件转es5
    transpile:
      process.env.NODE_ENV === 'production'
        ? ['tdesign-vue-next', 'echarts', 'vue-i18n']
        : [],
    // cssSourceMap: true,
  },
  css: [],
});
