import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import postCssPxToRem from 'postcss-pxtorem'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  publicDir: 'assets',
  plugins: [vue(), vueSetupExtend(), Components({
    resolvers: [VantResolver()],
  })],
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 40,
          propList: ['*']
        })
      ]
    }
  },
  server: {
    host: '0.0.0.0',
    port: 1234,
    open: true,
    proxy: {
      '/AppPeaManager': {
        /* 
          测试：192.168.0.14:18087
          吕俊杰：192.168.0.110:18089
          李振华：192.168.0.57:18089
          线上：112.29.103.165:1616
        */
        target: 'http://112.29.103.165:1616',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/AppPeaManager/, '/AppPeaManager')
      }
    }
  }
})