import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import path from 'path';
import DefineOptions from 'unplugin-vue-define-options/vite';
import { codeInspectorPlugin } from 'code-inspector-plugin';

const dir = (url: string): string => path.resolve(__dirname, url);

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@': dir('src'),
      '@mc': dir('src/modules/components'),
    },
  },
  plugins: [
    DefineOptions(),
    uni(),
    codeInspectorPlugin({
      bundler: 'vite',
    }),
  ],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: "@import '@/styles/variate.scss';@import '@/styles/theme.scss';",
      },
    },
  },
  server: {
    port: 1234,
    open: true,
  },
  // server: {
  //   port: 5173,
  //   open: true,
  //   proxy: {
  //     '/api': {
  //       target: 'http://127.0.0.1:9053',
  //       // target: 'https://test.pi.xuexiaole.com',
  //       changeOrigin: true,
  //     },
  //   },
  // },
});
