File tree 2 files changed +39
-10
lines changed 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'
3
3
import Header from './Header'
4
4
import Main from './Main'
5
5
import Sidebar from './Sidebar'
6
+ import Spinner from './common/Spinner'
7
+ import conf from '../conf'
6
8
7
9
import '../styles/App.styl'
8
10
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
+ }
18
43
19
44
export default App
Original file line number Diff line number Diff line change @@ -109,6 +109,9 @@ module.exports = () => {
109
109
'xml' ,
110
110
'yaml' ,
111
111
'django' ]
112
+ const assetsPath = process . env . ASSETS_PATH == null
113
+ ? '/'
114
+ : process . env . ASSETS_PATH
112
115
113
116
const conf = {
114
117
// Assume we are targeting production environments by default; the value
@@ -145,7 +148,7 @@ module.exports = () => {
145
148
output : {
146
149
filename : '[name].[chunkhash].js' ,
147
150
path : path . resolve ( __dirname , 'dist' ) ,
148
- publicPath : process . env . ASSET_PATH || '/' ,
151
+ publicPath : assetsPath ,
149
152
} ,
150
153
151
154
module : {
@@ -219,6 +222,7 @@ module.exports = () => {
219
222
new webpack . EnvironmentPlugin ( {
220
223
API_BASE_URI : null ,
221
224
RAW_SNIPPET_URI_FORMAT : null ,
225
+ RUNTIME_CONF_URI : `${ assetsPath } conf.json` ,
222
226
} ) ,
223
227
224
228
// Similar to JavaScript, we use [chunkhash] in order to invalidate
You can’t perform that action at this time.
0 commit comments