实现 nacos + traefik,改了很多东西!!!
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||
@@ -7,26 +7,30 @@ import { fileURLToPath, URL } from "node:url";
|
||||
import { nacosServiceManage } from "nacos-federation";
|
||||
|
||||
|
||||
export default defineConfig(async () => {
|
||||
const client = new nacosServiceManage({
|
||||
serverList: '192.168.31.100:8848',
|
||||
serviceName: 'app-product',
|
||||
port: 1301
|
||||
})
|
||||
const sharedUrl = await client.find("app-shared")
|
||||
export default defineConfig(async ({ mode }) => {
|
||||
|
||||
const env = loadEnv(mode, process.cwd());
|
||||
|
||||
await nacosServiceManage.create({
|
||||
serverList: env.VITE_NACOS_ADDRESS,
|
||||
serviceName: env.VITE_SERVER_NAME,
|
||||
port: Number(env.VITE_SERVER_PORT)
|
||||
});
|
||||
// const sharedUrl = await nacos.find(env.VITE_MODEL_SHARED_NAME)
|
||||
|
||||
return {
|
||||
base: `/${ env.VITE_SERVER_NAME }/`,
|
||||
server: {
|
||||
port: 1301,
|
||||
port: Number(env.VITE_SERVER_PORT),
|
||||
host: '0.0.0.0',
|
||||
strictPort: true,
|
||||
cors: true
|
||||
},
|
||||
plugins: [
|
||||
federation({
|
||||
name: 'product',
|
||||
name: env.VITE_SERVER_NAME,
|
||||
remotes: {
|
||||
shared: `${ sharedUrl }/assets/remoteEntry.js`
|
||||
shared: `http://${ env.VITE_TRAEFIK_ADDRESS }/${ env.VITE_MODEL_SHARED_NAME }/assets/remoteEntry.js`
|
||||
},
|
||||
exposes: { // 暴露给主应用的资源(按功能分组)
|
||||
'./ProductDomain': './src/domains/product/index.ts', // 领域层(实体、服务、接口等)
|
||||
|
||||
Reference in New Issue
Block a user