将vite.config.ts中的base 改到插件 nacos-federation中实现,简化代码
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Plugin } from 'vite';
|
||||
import { loadEnv, Plugin, UserConfig } from 'vite';
|
||||
import { nacosServiceManage, RegisterOptions } from './nacosServiceManage';
|
||||
|
||||
export function nacosRegVitePlugin(options?: Partial<RegisterOptions>): Plugin {
|
||||
@@ -6,6 +6,13 @@ export function nacosRegVitePlugin(options?: Partial<RegisterOptions>): Plugin {
|
||||
|
||||
return {
|
||||
name: 'vite-plugin-nacos',
|
||||
async config(userConfig: UserConfig, { mode }) {
|
||||
// 修改base,增加资源来源地址,修复资源错误加载的问题
|
||||
const env = loadEnv(mode, process.cwd());
|
||||
return {
|
||||
base: `${ env.VITE_PREFIX }${ env.VITE_TRAEFIK_ADDRESS }/${ env.VITE_SERVER_NAME }/`,
|
||||
}
|
||||
},
|
||||
async configResolved(config) {
|
||||
|
||||
// 安全检查:确保 config.define 存在
|
||||
|
||||
Reference in New Issue
Block a user