File tree Expand file tree Collapse file tree 2 files changed +39
-10
lines changed Expand file tree Collapse file tree 2 files changed +39
-10
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,42 @@ import React from 'react'
33import Header from './Header'
44import Main from './Main'
55import Sidebar from './Sidebar'
6+ import Spinner from './common/Spinner'
7+ import conf from '../conf'
68
79import '../styles/App.styl'
810
9- const App = ( ) => (
10- [
11- < Header key = "header" /> ,
12- < div className = "content" key = "content" >
13- < Sidebar />
14- < Main />
15- </ div > ,
16- ]
17- )
11+ class App extends React . Component {
12+ constructor ( props ) {
13+ super ( props )
14+ this . state = {
15+ isLoading : true ,
16+ }
17+
18+ fetch ( process . env . RUNTIME_CONF_URI )
19+ . then ( ( response ) => {
20+ if ( response . status === 404 ) {
21+ return { }
22+ }
23+ return response . json ( )
24+ } )
25+ . then ( json => Object . assign ( conf , json ) )
26+ . then ( ( ) => this . setState ( { isLoading : false } ) )
27+ }
28+
29+ render ( ) {
30+ if ( this . state . isLoading ) {
31+ return < Spinner />
32+ }
33+
34+ return [
35+ < Header key = "header" /> ,
36+ < div className = "content" key = "content" >
37+ < Sidebar />
38+ < Main />
39+ </ div > ,
40+ ]
41+ }
42+ }
1843
1944export default App
Original file line number Diff line number Diff line change @@ -109,6 +109,9 @@ module.exports = () => {
109109 'xml' ,
110110 'yaml' ,
111111 'django' ]
112+ const assetsPath = process . env . ASSETS_PATH == null
113+ ? '/'
114+ : process . env . ASSETS_PATH
112115
113116 const conf = {
114117 // Assume we are targeting production environments by default; the value
@@ -145,7 +148,7 @@ module.exports = () => {
145148 output : {
146149 filename : '[name].[chunkhash].js' ,
147150 path : path . resolve ( __dirname , 'dist' ) ,
148- publicPath : process . env . ASSET_PATH || '/' ,
151+ publicPath : assetsPath ,
149152 } ,
150153
151154 module : {
@@ -219,6 +222,7 @@ module.exports = () => {
219222 new webpack . EnvironmentPlugin ( {
220223 API_BASE_URI : null ,
221224 RAW_SNIPPET_URI_FORMAT : null ,
225+ RUNTIME_CONF_URI : `${ assetsPath } conf.json` ,
222226 } ) ,
223227
224228 // Similar to JavaScript, we use [chunkhash] in order to invalidate
You can’t perform that action at this time.
0 commit comments