Commit db0e6ab7 authored by Jure's avatar Jure

Use react-hot-loader

parent 93e3ff7e
.DS_Store
node_modules/
api/db/*
import React, { Component, PropTypes } from 'react'
import { ReduxRouter } from 'redux-router'
import { Provider } from 'react-redux'
export default class Root extends Component {
render () {
const { store } = this.props
return (
<Provider store={store}>
<div>
<ReduxRouter />
</div>
</Provider>
)
}
}
Root.propTypes = {
store: PropTypes.object.isRequired
}
2016/06/09-16:01:48.519358 70000051c000 Recovering log #58
2016/06/09-16:01:48.520633 70000051c000 Level-0 table #61: started
2016/06/09-16:01:48.521216 70000051c000 Level-0 table #61: 237 bytes OK
2016/06/09-16:01:48.522355 70000051c000 Delete type=0 #58
2016/06/09-16:01:48.522448 70000051c000 Delete type=3 #56
2016/06/09-15:58:26.395746 700000499000 Recovering log #55
2016/06/09-15:58:26.396820 700000499000 Level-0 table #57: started
2016/06/09-15:58:26.397551 700000499000 Level-0 table #57: 237 bytes OK
2016/06/09-15:58:26.399070 700000499000 Delete type=0 #55
2016/06/09-15:58:26.399184 700000499000 Delete type=3 #53
2016/06/09-15:58:26.399668 70000059f000 Compacting 4@0 + 1@1 files
2016/06/09-15:58:26.400904 70000059f000 Generated table #59: 34 keys, 3100 bytes
2016/06/09-15:58:26.400932 70000059f000 Compacted 4@0 + 1@1 files => 3100 bytes
2016/06/09-15:58:26.401216 70000059f000 compacted to: files[ 0 1 0 0 0 0 0 ]
2016/06/09-15:58:26.401331 70000059f000 Delete type=2 #46
2016/06/09-15:58:26.401461 70000059f000 Delete type=2 #48
2016/06/09-15:58:26.401568 70000059f000 Delete type=2 #51
2016/06/09-15:58:26.401648 70000059f000 Delete type=2 #54
2016/06/09-15:58:26.401758 70000059f000 Delete type=2 #57
import React from 'react'
import { render } from 'react-dom'
import React from '../node_modules/core/node_modules/react'
import { render } from '../node_modules/core/node_modules/react-dom'
import configureStore from '../node_modules/core/app/store/configureStore'
import Root from '../node_modules/core/app/components/Root'
import { AppContainer } from 'react-hot-loader'
let store = configureStore()
render(
<Root store={store} />,
document.getElementById('root')
<AppContainer component={Root} props={{ store }} />,
document.getElementById('root')
)
if (module.hot) {
module.hot.accept('../node_modules/core/app/components/Root', () => {
render(
<AppContainer
component={require('../node_modules/core/app/components/Root').default}
props={{ store }}
/>,
document.getElementById('root')
)
})
}
import React from '../../../node_modules/core/node_modules/react'
import { LinkContainer } from '../../../node_modules/core/node_modules/react-router-bootstrap'
import { Navbar, Nav, NavItem, NavbarBrand } from '../../../node_modules/core/node_modules/react-bootstrap'
import AuthHelper from '../../../node_modules/core/app/helpers/AuthHelper'
import NavbarUser from '../../../node_modules/core/app/components/Navigation/NavbarUser'
export default class Navigation extends React.Component {
render () {
const { actions, auth } = this.props
let logoutButtonIfAuthenticated
if (auth.isAuthenticated) {
logoutButtonIfAuthenticated = <NavbarUser
roles={auth.roles}
username={auth.username}
switchRole={actions.switchRole}
onLogoutClick={actions.logoutUser}
/>
}
return (
<Navbar fluid>
<Navbar.Header>
<NavbarBrand>
<a href='#'><img src='/science.png' alt='science'/></a>
</NavbarBrand>
</Navbar.Header>
<Nav eventKey={0}>
<LinkContainer to='/manage/posts'>
<NavItem>Science Posts</NavItem>
</LinkContainer>p
{ AuthHelper.showForUser(auth, 'users') &&
<LinkContainer to='/manage/users'>
<NavItem>Users</NavItem>
</LinkContainer>
}
<LinkContainer to='/manage/users'>
<NavItem>She's alive!</NavItem>
</LinkContainer>
</Nav>
{ logoutButtonIfAuthenticated }
</Navbar>
)
}
}
Navigation.propTypes = {
actions: React.PropTypes.object.isRequired,
auth: React.PropTypes.object
}
import React from 'react'
import { Route } from 'react-router'
import React from '../node_modules/core/node_modules/react'
import { Route } from '../node_modules/core/node_modules/react-router'
import { requireAuthentication } from '../node_modules/core/components/AuthenticatedComponent'
import { requireAuthentication } from '../node_modules/core/app/components/AuthenticatedComponent'
// Manage
import Manage from '../node_modules/core/components/Manage'
import PostsManager from '../node_modules/core/components/PostsManager/PostsManager'
import ScienceWriter from '../node_modules/core/components/ScienceWriter/ScienceWriter'
import UsersManager from '../node_modules/core/components/UsersManager/UsersManager'
import Manage from '../node_modules/core/app/components/Manage'
import PostsManager from '../node_modules/core/app/components/PostsManager/PostsManager'
import ScienceWriter from '../node_modules/core/app/components/ScienceWriter/ScienceWriter'
import UsersManager from '../node_modules/core/app/components/UsersManager/UsersManager'
// Public
import Blog from '../node_modules/core/components/Blog/Blog'
import ScienceReader from '../node_modules/core/components/ScienceReader/ScienceReader'
import Blog from '../node_modules/core/app/components/Blog/Blog'
import ScienceReader from '../node_modules/core/app/components/ScienceReader/ScienceReader'
// Authentication
import Login from '../node_modules/core/components/Login/Login'
import Signup from '../node_modules/core/components/Signup/Signup'
import Login from '../node_modules/core/app/components/Login/Login'
import Signup from '../node_modules/core/app/components/Signup/Signup'
export default (
<Route>
......
......@@ -3,5 +3,5 @@ module.exports = {
API_ENDPOINT: '/api',
theme: 'pepper',
routes: 'app/routes.jsx',
navigation: 'app/components/Navigation/Xavigation.jsx'
navigation: 'app/components/Navigation/Navigation.jsx'
}
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('../../../node_modules/core/node_modules/react');
var _react2 = _interopRequireDefault(_react);
var _reactRouterBootstrap = require('../../../node_modules/core/node_modules/react-router-bootstrap');
var _reactBootstrap = require('../../../node_modules/core/node_modules/react-bootstrap');
var _AuthHelper = require('../../../node_modules/core/app/helpers/AuthHelper');
var _AuthHelper2 = _interopRequireDefault(_AuthHelper);
var _NavbarUser = require('../../../node_modules/core/app/components/Navigation/NavbarUser');
var _NavbarUser2 = _interopRequireDefault(_NavbarUser);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Navigation = function (_React$Component) {
_inherits(Navigation, _React$Component);
function Navigation() {
_classCallCheck(this, Navigation);
return _possibleConstructorReturn(this, Object.getPrototypeOf(Navigation).apply(this, arguments));
}
_createClass(Navigation, [{
key: 'render',
value: function render() {
var _props = this.props;
var actions = _props.actions;
var auth = _props.auth;
var logoutButtonIfAuthenticated = void 0;
if (auth.isAuthenticated) {
logoutButtonIfAuthenticated = _react2.default.createElement(_NavbarUser2.default, {
roles: auth.roles,
username: auth.username,
switchRole: actions.switchRole,
onLogoutClick: actions.logoutUser
});
}
return _react2.default.createElement(
_reactBootstrap.Navbar,
{ fluid: true },
_react2.default.createElement(
_reactBootstrap.Navbar.Header,
null,
_react2.default.createElement(
_reactBootstrap.NavbarBrand,
null,
_react2.default.createElement(
'a',
{ href: '#' },
_react2.default.createElement('img', { src: '/science.png', alt: 'science' })
)
)
),
_react2.default.createElement(
_reactBootstrap.Nav,
{ eventKey: 0 },
_react2.default.createElement(
_reactRouterBootstrap.LinkContainer,
{ to: '/manage/posts' },
_react2.default.createElement(
_reactBootstrap.NavItem,
null,
'Science Posts'
)
),
'p',
_AuthHelper2.default.showForUser(auth, 'users') && _react2.default.createElement(
_reactRouterBootstrap.LinkContainer,
{ to: '/manage/users' },
_react2.default.createElement(
_reactBootstrap.NavItem,
null,
'Users'
)
),
_react2.default.createElement(
_reactRouterBootstrap.LinkContainer,
{ to: '/manage/users' },
_react2.default.createElement(
_reactBootstrap.NavItem,
null,
'She\'s alive!'
)
)
),
logoutButtonIfAuthenticated
);
}
}]);
return Navigation;
}(_react2.default.Component);
exports.default = Navigation;
Navigation.propTypes = {
actions: _react2.default.PropTypes.object.isRequired,
auth: _react2.default.PropTypes.object
};
......@@ -10,20 +10,17 @@ console.log('WHAT', config)
// but excluding its node_modules.
var commonLoaders = [
{
/*
* TC39 categorises proposals for babel in 4 stages
* Read more http://babeljs.io/docs/usage/experimental/
*/
test: /\.js$|\.jsx$/,
loader: 'babel',
// Reason why we put this here instead of babelrc
// https://github.com/gaearon/react-transform-hmr/issues/5#issuecomment-142313637
query: {
'presets': ['react-hmre', 'es2015', 'react'],
'cacheDirectory': true
presets: ['es2015', 'react'],
plugins: ['react-hot-loader/babel']
},
include: path.join(__dirname, '..', 'app'),
exclude: path.join(__dirname, '/node_modules/')
include: [
new RegExp(path.join(__dirname, '../node_modules/core/app')),
new RegExp(path.join(__dirname, '../app')),
new RegExp(path.join(__dirname, '../../core/app')) // TODO: Temp while linked.
]
},
{ test: /\.png$/, loader: 'url-loader' },
{
......@@ -43,6 +40,8 @@ var commonLoaders = [
]
console.log(commonLoaders[0])
module.exports = [
{
// The configuration for the client
......@@ -51,8 +50,9 @@ module.exports = [
context: path.join(__dirname, '..', 'app'),
entry: {
app: [
'./app',
'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true'
'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true',
'react-hot-loader/patch',
'./app'
]
},
output: {
......@@ -67,7 +67,7 @@ module.exports = [
module: {
preLoaders: [{
test: /\.js$|\.jsx$/,
exclude: [/\/lens/, /\/substance/],
exclude: [/\/node_modules/, /\/lens/, /\/substance/],
loaders: ['eslint-loader']
}],
loaders: commonLoaders
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment