Unverified Commit 749a463a authored by liuzhe-lz's avatar liuzhe-lz Committed by GitHub
Browse files

Support prefix for webui static files (#3874)

parent af5551f9
...@@ -54,19 +54,16 @@ module.exports = function(webpackEnv) { ...@@ -54,19 +54,16 @@ module.exports = function(webpackEnv) {
// Webpack uses `publicPath` to determine where the app is being served from. // Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path. // It requires a trailing slash, or the file assets will get an incorrect path.
// In development, we always serve from the root. This makes config easier. // In development, we always serve from the root. This makes config easier.
const publicPath = isEnvProduction //const publicPath = isEnvProduction ? paths.servedPath : isEnvDevelopment && '/';
? paths.servedPath const publicPath = './';
: isEnvDevelopment && '/';
// Some apps do not use client-side routing with pushState. // Some apps do not use client-side routing with pushState.
// For these, "homepage" can be set to "." to enable relative asset paths. // For these, "homepage" can be set to "." to enable relative asset paths.
const shouldUseRelativeAssetPaths = publicPath === './'; const shouldUseRelativeAssetPaths = true;
// `publicUrl` is just like `publicPath`, but we will provide it to our app // `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz. // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
const publicUrl = isEnvProduction const publicUrl = '.';
? publicPath.slice(0, -1)
: isEnvDevelopment && '';
// Get environment variables to inject into our app. // Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl); const env = getClientEnvironment(publicUrl);
......
import * as React from 'react'; import * as React from 'react';
import { NavLink } from 'react-router-dom'; import { NavLink } from 'react-router-dom';
import { getPrefix } from '../../static/function';
const OVERVIEWTABS = ( const OVERVIEWTABS = (
<NavLink to='/oview' activeClassName='selected' className='common-tabs'> <NavLink to='/oview' activeClassName='selected' className='common-tabs'>
Overview Overview
...@@ -15,7 +17,7 @@ const DETAILTABS = ( ...@@ -15,7 +17,7 @@ const DETAILTABS = (
const NNILOGO = ( const NNILOGO = (
<NavLink to='/oview'> <NavLink to='/oview'>
<img src='/logo.png' alt='NNI logo' style={{ height: 40 }} /> <img src={(getPrefix() || '') + '/logo.png'} alt='NNI logo' style={{ height: 40 }} />
</NavLink> </NavLink>
); );
......
...@@ -17,7 +17,7 @@ ReactDOM.render( ...@@ -17,7 +17,7 @@ ReactDOM.render(
<Suspense <Suspense
fallback={ fallback={
<div className='loading'> <div className='loading'>
<img src='/loading.gif' /> <img src={(path || '') + '/loading.gif'} />
</div> </div>
} }
> >
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment