实现 nacos + traefik,改了很多东西!!!
This commit is contained in:
0
front-end/app-shared/.env.development
Normal file
0
front-end/app-shared/.env.development
Normal file
8
front-end/app-shared/.env.production
Normal file
8
front-end/app-shared/.env.production
Normal file
@@ -0,0 +1,8 @@
|
||||
# Nacos 配置中心ip:端口
|
||||
VITE_NACOS_ADDRESS=192.168.31.101:8848
|
||||
|
||||
# 注册到 Nacos 的服务名称(微前端模块名称)
|
||||
VITE_SERVER_NAME=app-shared
|
||||
|
||||
# 注册到 Nacos 的端口,也是前端运行的端口
|
||||
VITE_SERVER_PORT=1333
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.12.2",
|
||||
"nacos-federation": "^1.0.2"
|
||||
"nacos-federation": "link:../nacos-federation"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@originjs/vite-plugin-federation": "^1.4.1",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class HttpConfig {
|
||||
public static DevBaseUrl: string = "http://127.0.0.1:3000/api"
|
||||
public static prodBaseUrl: string = "http://127.0.0.1:3000/api/"
|
||||
public static DevBaseUrl: string = "http://127.0.0.1:3210/api"
|
||||
public static prodBaseUrl: string = "http://127.0.0.1:3210/api/"
|
||||
public static apiList: string = ""
|
||||
}
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
import { defineConfig, UserConfig } from 'vite'
|
||||
import { defineConfig, loadEnv, UserConfig } from 'vite'
|
||||
import federation from "@originjs/vite-plugin-federation";
|
||||
import { nacosServiceManage } from "nacos-federation";
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig(async (): Promise<UserConfig> => {
|
||||
new nacosServiceManage({
|
||||
serverList: '192.168.31.100:8848',
|
||||
serviceName: 'app-shared',
|
||||
port: 1333
|
||||
})
|
||||
|
||||
export default defineConfig(async ({ mode }): Promise<UserConfig> => {
|
||||
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)
|
||||
});
|
||||
|
||||
return {
|
||||
base: `/${ env.VITE_SERVER_NAME }/`,
|
||||
server: {
|
||||
port: 1333,
|
||||
port: Number(env.VITE_SERVER_PORT),
|
||||
host: '0.0.0.0',
|
||||
strictPort: true,
|
||||
cors: true
|
||||
},
|
||||
plugins: [
|
||||
federation({
|
||||
name: 'shared',
|
||||
name: env.VITE_SERVER_NAME,
|
||||
exposes: {
|
||||
"./config": "./src/config/index.ts",
|
||||
"./infra": "./src/infra/index.ts",
|
||||
@@ -42,4 +44,4 @@ export default defineConfig(async (): Promise<UserConfig> => {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user