const { resolve } = require('path')
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import glsl from 'vite-plugin-glsl'
const vueJsx = require('@vitejs/plugin-vue-jsx')
const legacy = require('@vitejs/plugin-legacy')

const proxyUrl = 'https://test.lexiaoya.cn/' // test 环境
// const proxyUrl = 'http://192.168.3.70:8989/' // test 环境
// const proxyUrl = 'https://online.colexiu.com/' // online 环境

export default defineConfig({
  base: '/orchestra-music-score',
  build: {
    rollupOptions: {
      input: {
        index: resolve(__dirname, 'index.html'),
        orchestra: resolve(__dirname, 'orchestra.html'),
        colexiu: resolve(__dirname, 'colexiu.html'),
        'colexiu-report-share': resolve(__dirname, 'colexiu-report-share.html'),
        'colexiu-report': resolve(__dirname, 'colexiu-report.html'),
        'colxiu-website': resolve(__dirname, 'colxiu-website.html'),
        'colxiu-share': resolve(__dirname, 'colexiu-share.html'),
        'music-sheet': resolve(__dirname, 'music-sheet.html'),
      },
    },
  },
  plugins: [
    vue(),
    glsl(),
    vueJsx(),
    legacy({
      targets: ['> 0.25%, not dead'],
      ignoreBrowserslistConfig: true,
    }),
  ],
  server: {
    port: 3000,
    cors: true,
    proxy: {
      '/api-student': {
        target: proxyUrl,
        changeOrigin: true,
      },
      '/api-teacher': {
        target: proxyUrl,
        changeOrigin: true,
      },
      '/api-backend': {
        target: proxyUrl,
        changeOrigin: true,
      }
    },
  },
  preview: {
    port: 3000,
    host: '192.168.3.114'
  }
})
