Skip to content

Commit

Permalink
Render main react component
Browse files Browse the repository at this point in the history
  • Loading branch information
Remchi committed Jun 16, 2016
1 parent 9e208c5 commit 64e99bb
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": [ "es2015" ]
"presets": [ "es2015", "react" ]
}
7 changes: 7 additions & 0 deletions client/components/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

export default () => {
return (
<h1>Hello from react</h1>
);
}
5 changes: 5 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';
import { render } from 'react-dom';
import App from './components/App';

render(<App />, document.getElementById('app'));
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.10.1",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"nodemon": "^1.9.2"
"babel-preset-react": "^6.5.0",
"nodemon": "^1.9.2",
"webpack": "^1.13.1",
"webpack-dev-middleware": "^1.6.1"
},
"dependencies": {
"express": "^4.14.0"
"express": "^4.14.0",
"react": "^15.1.0",
"react-dom": "^15.1.0"
}
}
4 changes: 3 additions & 1 deletion server/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
</head>

<body>
<h1>!Hello World!</h1>
<div id="app"></div>

<script src="bundle.js"></script>
</body>

</html>
6 changes: 6 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import express from 'express';
import path from 'path';

import webpack from 'webpack';
import webpackMiddleware from 'webpack-dev-middleware';
import webpackConfig from '../webpack.config.dev';

let app = express();

app.use(webpackMiddleware(webpack(webpackConfig)));

app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, './index.html'));
});
Expand Down
21 changes: 21 additions & 0 deletions webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import path from 'path'

export default {
devtools: 'eval-source-map',
entry: path.join(__dirname, '/client/index.js'),
output: {
path: '/'
},
module: {
loaders: [
{
test: /\.js$/,
include: path.join(__dirname, 'client'),
loaders: [ 'babel' ]
}
]
},
resolve: {
extentions: [ '', '.js' ]
}
}

0 comments on commit 64e99bb

Please sign in to comment.