Skip to content

Commit fbd8be5

Browse files
author
Peng.Li
committed
add react
1 parent 7ef0dcc commit fbd8be5

File tree

6 files changed

+35
-17
lines changed

6 files changed

+35
-17
lines changed
File renamed without changes.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"start": "babel-node app/app.js --ignore 'node_modules/' || exit 0",
7+
"start": "babel-node app/server.js --ignore 'node_modules/' || exit 0",
88
"test": "echo \"Error: no test specified\" && exit 1"
99
},
1010
"keywords": [],
@@ -22,7 +22,12 @@
2222
},
2323
"dependencies": {
2424
"babel-preset-es2015": "^6.13.2",
25+
"babel-preset-react": "^6.11.1",
2526
"body-parser": "^1.15.2",
26-
"express": "^4.14.0"
27+
"express": "^4.14.0",
28+
"jquery": "^3.1.0",
29+
"lodash": "^4.14.1",
30+
"react": "^15.3.0",
31+
"react-dom": "^15.3.0"
2732
}
2833
}

public/entry.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

public/entry.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Hello from './hello.jsx';
2+
import React from 'react';
3+
import ReactDOM from 'react-dom';
4+
5+
ReactDOM.render(
6+
<Hello />,
7+
document.getElementById("content")
8+
);
9+
10+
// Notice!!!
11+
// Following is required to make reloading happen
12+
if (module.hot) {
13+
module.hot.accept();
14+
}

public/hello.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
3+
class Hello extends React.Component {
4+
render() {
5+
return (<div>
6+
<h1>Hello world</h1>
7+
</div>)
8+
}
9+
}
10+
11+
export default Hello;

webpack.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const webpack = require('webpack');
22

33
module.exports = {
44
entry: [
5-
'./public/entry.js',
5+
'./public/entry.jsx',
66
'webpack-hot-middleware/client'
77
],
88
output: {
@@ -12,11 +12,11 @@ module.exports = {
1212
},
1313
module: {
1414
loaders: [{
15-
test: /\.js$/,
15+
test: /\.(js|jsx)$/,
1616
exclude: /node_modules/,
1717
loader: 'babel',
1818
query: {
19-
presets: ['es2015']
19+
presets: ['es2015', 'react']
2020
}
2121
}]
2222
},

0 commit comments

Comments
 (0)