-
Notifications
You must be signed in to change notification settings - Fork 51
/
app.js
122 lines (103 loc) · 3.42 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* app.js
*
* This is the entry file for the application, only setup and boilerplate
* code.
*/
// Needed for redux-saga es6 generator support
import '@babel/polyfill';
// Import all the third party stuff
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import FontFaceObserver from 'fontfaceobserver';
import history from 'utils/history';
import 'sanitize.css/sanitize.css';
// Import root app
import App from 'containers/App';
// Import Language Provider
import LanguageProvider from 'containers/LanguageProvider/index';
// Load the favicon, the manifest.json file and the .htaccess file
/* eslint-disable import/no-unresolved, import/extensions */
import '!file-loader?name=[name].[ext]!./images/favicon.png';
import '!file-loader?name=[name].[ext]!./osd.xml';
import '!file-loader?name=[name].[ext]!./sitemap.xml';
import 'file-loader?name=.htaccess!./.htaccess';
import 'file-loader?name=[name].[ext]!./extras/404.html';
/* eslint-enable import/no-unresolved, import/extensions */
// Import bootstrap styles
import 'bootstrap/dist/css/bootstrap.css';
// Import react-vis styles
import 'react-vis/dist/style.css';
// Import components
import SocketClient from 'components/SocketClient';
import configureStore from './configureStore';
// Import i18n messages
import { translationMessages } from './i18n';
// // Import CSS reset and Global Styles
// import './global-styles';
//
// // Import SASS responsive styles
import './responsive-styles.scss';
//
// // Import theming
// import './theming/theming.scss';
//
// // Import theming modes
import './theming/theming-modes.scss';
import appInfo from '../package.json';
console.info('app version: %s', appInfo.version);
// Observe loading of Open Sans (to remove open sans, remove the <link> tag in
// the index.html file and this observer)
const openSansObserver = new FontFaceObserver('Open Sans', {});
// verify if it's running in prod environment
// const isProd = process.env.NODE_ENV === 'production';
// When Open Sans is loaded, add a font-family using Open Sans to the body
openSansObserver.load().then(
() => {
document.body.classList.add('fontLoaded');
},
() => {
document.body.classList.remove('fontLoaded');
},
);
// Create redux store with history
const initialState = {};
const socketClient = new SocketClient();
const store = configureStore(initialState, socketClient, history);
const MOUNT_NODE = document.getElementById('app');
const render = messages => {
ReactDOM.render(
<Provider store={store}>
<LanguageProvider messages={messages}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</LanguageProvider>
</Provider>,
MOUNT_NODE,
);
};
if (module.hot) {
// Hot reloadable React components and translation json files
// modules.hot.accept does not accept dynamic dependencies,
// have to be constants at compile-time
module.hot.accept(['./i18n', 'containers/App'], () => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
render(translationMessages);
});
}
// Chunked polyfill for browsers without Intl support
if (!window.Intl) {
new Promise(resolve => {
resolve(import('intl'));
})
.then(() => Promise.all([import('intl/locale-data/jsonp/en.js')]))
.then(() => render(translationMessages))
.catch(err => {
throw err;
});
} else {
render(translationMessages);
}