diff --git a/packages/umi-build-dev/src/getRouterContent.js b/packages/umi-build-dev/src/getRouterContent.js index 666628124472..32a81282c4a2 100644 --- a/packages/umi-build-dev/src/getRouterContent.js +++ b/packages/umi-build-dev/src/getRouterContent.js @@ -34,7 +34,7 @@ function getRouteComponents(routeConfig, config = {}, paths) { const { loading } = config; let loadingOpts = ''; if (loading) { - loadingOpts = `loading: require('${join(paths.cwd, loading)}').default,`; + loadingOpts = `, loading: require('${join(paths.cwd, loading)}').default,`; } const routerComponents = Object.keys(routeConfig).map(key => { @@ -46,9 +46,13 @@ function getRouteComponents(routeConfig, config = {}, paths) { : '() =>
Compiling...
'; return ` `; } else { - return ` import(/* webpackChunkName: '${normalizeEntry( + return ` import(/* webpackChunkName: '${normalizeEntry( routeConfig[key], - )}' */'${pageJSFile}'), { callback: (err) => callback('${key}', err), ${loadingOpts} }) }>`; + )}' */'${pageJSFile}'), { callback: (err) => callback('${key}', err)${ + loadingOpts + } }) }>`; } });