UNPKG

3.25 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.boot = boot;
7
8var _debug = require('debug');
9
10var _debug2 = _interopRequireDefault(_debug);
11
12var _invariant = require('invariant');
13
14var _invariant2 = _interopRequireDefault(_invariant);
15
16var _react = require('react');
17
18var _react2 = _interopRequireDefault(_react);
19
20var _reactDom = require('react-dom');
21
22var _reactRouter = require('react-router');
23
24var _reactHotLoader = require('react-hot-loader');
25
26var _Router = require('./Router');
27
28var _Router2 = _interopRequireDefault(_Router);
29
30function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
32_debug2.default.enable(__DEBUG__); /**
33 * @copyright 2016-present, Sitegen team
34 */
35
36var HOST_ELEMENT = 'main';
37
38function boot(routes) {
39 (0, _reactRouter.match)({ routes: routes, history: _reactRouter.browserHistory }, function (err, redirect, props) {
40 if (err) {
41 throw err;
42 } else if (redirect) {
43 (0, _invariant2.default)(false, 'Redirects are not supported');
44 } else {
45 (0, _reactDom.render)(_react2.default.createElement(
46 _reactHotLoader.AppContainer,
47 null,
48 _react2.default.createElement(_Router2.default, props)
49 ), document.getElementById(HOST_ELEMENT));
50 }
51 });
52}
53//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9hbmRyZXlwb3BwL1dvcmtzcGFjZS9zaXRlZ2VuL3NyYy9ib290LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O1FBZ0JnQixJLEdBQUEsSTs7QUFaaEI7Ozs7QUFHQTs7OztBQUNBOzs7O0FBQ0E7O0FBQ0E7O0FBQ0E7O0FBQ0E7Ozs7OztBQVBBLGdCQUFNLE1BQU4sQ0FBYSxTQUFiLEU7Ozs7QUFTQSxJQUFNLGVBQWUsTUFBckI7O0FBRU8sU0FBUyxJQUFULENBQWMsTUFBZCxFQUFzQjtBQUMzQiwwQkFBTSxFQUFDLGNBQUQ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