import fs from 'fs'
import path from 'path'
import { defineConfig } from 'vite'
import { createVuePlugin } from 'vite-plugin-vue2'
import checker from 'vite-plugin-checker'
export default defineConfig({
  base: process.env.BUILD_ENV === 'prod' ? 'https://webapp-pub.ezijing.com/website/prod/x-training/' : '/',
  plugins: [
    checker({
      eslint: {
        lintCommand: 'eslint "./src/**/*.{vue,js,jsx,ts,tsx}"'
      }
    }),
    createVuePlugin()
  ],
  server: {
    open: true,
    host: 'dev.ezijing.com',
    https: {
      key: fs.readFileSync(path.join(__dirname, './https/dev.ezijing.com.key')),
      cert: fs.readFileSync(path.join(__dirname, './https/dev.ezijing.com.pem'))
    },
    proxy: {
      '/api': 'https://x-training.ezijing.com'
    }
  },
  resolve: {
    alias: [
      {
        find: '@',
        replacement: path.resolve(__dirname, 'src')
      }
    ]
  },
  css: {
    // 禁用SASS警告提醒
    preprocessorOptions: { scss: { quietDeps: true, charset: false } }
  }
})
