@@ -18,14 +18,16 @@ import { getModuleMarker, normalizePath, parseExposeOptions } from '../utils'
1818import { EXTERNALS , SHARED , builderInfo , parsedOptions } from '../public'
1919import type { VitePluginFederationOptions } from 'types'
2020import type { PluginHooks } from '../../types/pluginHooks'
21- import { ViteDevServer } from 'vite'
21+ import { UserConfig , ViteDevServer } from 'vite'
2222import { importShared } from './import-shared'
23+ import { config } from 'process'
2324
2425export function devExposePlugin (
2526 options : VitePluginFederationOptions
2627) : PluginHooks {
2728 parsedOptions . devExpose = parseExposeOptions ( options )
2829 let moduleMap = ''
30+ let baseDir = '/'
2931
3032 // exposes module
3133 for ( const item of parsedOptions . devExpose ) {
@@ -37,7 +39,7 @@ export function devExposePlugin(
3739 return __federation_import('/${ importPath } ', '/@fs/${ exposeFilepath } ').then(module =>Object.keys(module).every(item => exportSet.has(item)) ? () => module.default : () => module)},`
3840 }
3941 const remoteFile = `(${ importShared } )();
40- import RefreshRuntime from "/ @react-refresh"
42+ import RefreshRuntime from "${ baseDir } @react-refresh"
4143 RefreshRuntime.injectIntoGlobalHook(window)
4244 window.$RefreshReg$ = () => {}
4345 window.$RefreshSig$ = () => (type) => type
@@ -73,6 +75,11 @@ export function devExposePlugin(
7375
7476 return {
7577 name : 'originjs:expose-development' ,
78+ config : ( config : UserConfig ) => {
79+ if ( config . base ) {
80+ baseDir = config . base
81+ }
82+ } ,
7683 configureServer : ( server : ViteDevServer ) => {
7784 const remoteFilePath = `${ builderInfo . assetsDir } /${ options . filename } `
7885 server . middlewares . use ( ( req , res , next ) => {
0 commit comments