import {
	fileURLToPath,
	URL
} from 'node:url'
import topLevelAwait from 'vite-plugin-top-level-await'
import {
	defineConfig
} from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
	base: "./",
	plugins: [
		vue(),
		topLevelAwait({
			promiseExportName: '__tla',
			promiseImportName: i=> `__tla_${i}`
		})
	],
	 build:{
	    target:['es2020']
	  },
	resolve: {
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url))
		}
	},
	server: {

		host: "0.0.0.0",
		proxy: {
			'/api': {
				target: 'http://localhostcommon/api', // 实际的API服务器地址
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, '') // 如果API地址有前缀，可以进行转写
			}
		}
	}
})