import { fileURLToPath, URL } from 'node:url';

import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';

export default ({ mode }) => {
  process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') };
  return defineConfig({
    base: process.env.VITE_WEB_CONTEXT_PATH,
    define: {
      'import.meta.env': process.env,
    },
    plugins: [vue(), vueJsx()],
   
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
       
      },
    },
    
    build: {
      chunkSizeWarningLimit: 500000,
      outDir: process.env.VITE_DIST_PATH,
    },
    server: {
      port: '8081',
    },
  });
};
