app.js 1.56 KB
Newer Older
dengxiaofeng's avatar
dengxiaofeng committed
1
import '!file-loader?name=[name].[ext]!./images/favicon.ico';
dengxiaofeng's avatar
dengxiaofeng committed
2
import './global.less';
dengxiaofeng's avatar
dengxiaofeng committed
3
import '@babel/polyfill';
dengxiaofeng's avatar
dengxiaofeng committed
4
import 'antd/dist/antd.less';
dengxiaofeng's avatar
dengxiaofeng committed
5 6 7 8 9 10
import 'file-loader?name=.htaccess!./.htaccess'; // eslint-disable-line import/extensions
import 'sanitize.css/sanitize.css';

import React from 'react';
import ReactDOM from 'react-dom';

邓晓峰's avatar
邓晓峰 committed
11 12
import { ConfigProvider } from 'antd';
import zhCN from 'antd/es/locale/zh_CN';
dengxiaofeng's avatar
dengxiaofeng committed
13 14
import { ConnectedRouter } from 'connected-react-router/immutable';
import Immutable from 'immutable';
dengxiaofeng's avatar
dengxiaofeng committed
15 16
import { Provider } from 'react-redux';

邓晓峰's avatar
邓晓峰 committed
17 18
import { PictureWallProvider } from '@/components/Upload/context';

dengxiaofeng's avatar
dengxiaofeng committed
19
import configureStore from './configureStore';
dengxiaofeng's avatar
dengxiaofeng committed
20
import App from './containers/App';
21
import config from './routes/config';
邓晓峰's avatar
邓晓峰 committed
22 23
import history from './utils/history';

dengxiaofeng's avatar
dengxiaofeng committed
24
const initialState = Immutable.Map();
dengxiaofeng's avatar
dengxiaofeng committed
25 26 27 28 29 30
const store = configureStore(initialState, history);
const MOUNT_NODE = document.getElementById('app');
const render = () => {
  ReactDOM.render(
    <Provider store={store}>
      <ConnectedRouter history={history}>
陈前坚's avatar
陈前坚 committed
31
        <ConfigProvider locale={zhCN}>
32 33 34
          {/* <PictureWallProvider> */}
          <App routesConfig={config} />
          {/* </PictureWallProvider> */}
陈前坚's avatar
陈前坚 committed
35
        </ConfigProvider>
dengxiaofeng's avatar
dengxiaofeng committed
36 37 38 39 40 41
      </ConnectedRouter>
    </Provider>,
    MOUNT_NODE,
  );
};

dengxiaofeng's avatar
dengxiaofeng committed
42 43 44 45 46 47
if (module.hot) {
  module.hot.accept(['./containers/App'], () => {
    ReactDOM.unmountComponentAtNode(MOUNT_NODE);
    render();
  });
}
张烨's avatar
张烨 committed
48
if (MOUNT_NODE) {
dengxiaofeng's avatar
dengxiaofeng committed
49 50
  render();
}
dengxiaofeng's avatar
dengxiaofeng committed
51 52 53 54

if (process.env.NODE_ENV === 'production') {
  require('offline-plugin/runtime').install(); // eslint-disable-line global-require
}