import { defineConfig, loadEnv, UserConfig } from 'vite' import federation from "@originjs/vite-plugin-federation"; // @ts-ignore import vueJsx from '@vitejs/plugin-vue-jsx' // @ts-ignore import vue from '@vitejs/plugin-vue'; import visualizer from 'rollup-plugin-visualizer'; import { reg, init } from 'vite-plugin-nacos'; export default defineConfig(async ({ mode }): Promise => { const env = loadEnv(mode, process.cwd()); init(env) return { plugins: [ reg(), federation({ name: env.VITE_SERVER_NAME, exposes: { "./config": "./src/config/index.ts", "./infra": "./src/infra/index.ts", "./utils": "./src/utils/index.ts", "./element-plus": "./src/lib/element-plus.ts", "./normalize": "./src/styles/common/index.ts", "./pub": "./src/styles/pub/index.ts", }, shared: { vue: { import: false, generate: false, requiredVersion: '^3.5.18' }, axios: { requiredVersion: '^1.12.2' }, 'element-plus': { requiredVersion: '^2.11.3' } } }), vue(), vueJsx(), visualizer({ title: "共享模块依赖分析", filename: 'dist/stats.html', // 分析文件输出路径 open: false, // 构建完成后自动打开 gzipSize: true, // 显示gzip后的大小 brotliSize: true, // 显示brotli后的大小 }) ], build: { target: 'esnext', minify: false, cssCodeSplit: true, rollupOptions: { output: { format: 'esm', minifyInternalExports: false } } } } });