58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import { defineConfig, loadEnv, UserConfig } from 'vite'
|
|
import federation from "@originjs/vite-plugin-federation";
|
|
import { nacosRegVitePlugin } from "nacos-federation";
|
|
// @ts-ignore
|
|
import vue from '@vitejs/plugin-vue';
|
|
import visualizer from 'rollup-plugin-visualizer';
|
|
|
|
export default defineConfig(async ({ mode }): Promise<UserConfig> => {
|
|
const env = loadEnv(mode, process.cwd());
|
|
|
|
return {
|
|
server: {
|
|
port: Number(env.VITE_SERVER_PORT),
|
|
host: '0.0.0.0',
|
|
strictPort: true,
|
|
cors: true
|
|
},
|
|
plugins: [
|
|
nacosRegVitePlugin(),
|
|
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(),
|
|
visualizer({
|
|
title: "共享模块依赖分析",
|
|
filename: 'dist/stats.html', // 分析文件输出路径
|
|
open: false, // 构建完成后自动打开
|
|
gzipSize: true, // 显示gzip后的大小
|
|
brotliSize: true, // 显示brotli后的大小
|
|
})
|
|
],
|
|
build: {
|
|
target: 'esnext',
|
|
minify: false,
|
|
cssCodeSplit: true,
|
|
rollupOptions: {
|
|
input: './src/index.ts',
|
|
output: {
|
|
format: 'esm',
|
|
minifyInternalExports: false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}); |