parent
5f57586a7f
commit
888eff91d8
8 changed files with 105 additions and 3 deletions
@ -0,0 +1,4 @@ |
||||
{ |
||||
"presets": ["react"], |
||||
"plugins": ["react-hot-loader/babel"] |
||||
} |
@ -0,0 +1,9 @@ |
||||
<html> |
||||
<head> |
||||
<title>LED Toggle Demo</title> |
||||
</head> |
||||
<body> |
||||
<div id="root"></div> |
||||
<script src="./bundle.js"></script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,12 @@ |
||||
const express = require('express') |
||||
const app = express() |
||||
|
||||
app.use('/', express.static('dist')) |
||||
|
||||
app.get('/hello', function (req, res) { |
||||
res.send('Hello World!') |
||||
}) |
||||
|
||||
app.listen(3000, function () { |
||||
console.log('Example app listening on port 3000!') |
||||
}) |
@ -0,0 +1,11 @@ |
||||
import React from 'react'; |
||||
|
||||
export default class Site extends React.Component { |
||||
render() { |
||||
return ( |
||||
<div> |
||||
Hello React! |
||||
</div> |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,22 @@ |
||||
import React from 'react'; |
||||
import ReactDOM from 'react-dom'; |
||||
import 'react-hot-loader/patch'; |
||||
import { AppContainer } from 'react-hot-loader'; |
||||
|
||||
import App from './app'; |
||||
|
||||
|
||||
const render = Component => { |
||||
ReactDOM.render( |
||||
<AppContainer> |
||||
<Component /> |
||||
</AppContainer>, |
||||
document.getElementById('root') |
||||
) |
||||
} |
||||
|
||||
render(App) |
||||
|
||||
if (module.hot) { |
||||
module.hot.accept('./app', () => { render(App) }) |
||||
} |
@ -0,0 +1,28 @@ |
||||
const path = require('path'); |
||||
const webpack = require('webpack'); |
||||
|
||||
module.exports = { |
||||
entry: './src/index.js', |
||||
plugins: [ |
||||
new webpack.HotModuleReplacementPlugin(), |
||||
], |
||||
output: { |
||||
filename: 'bundle.js', |
||||
path: path.resolve(__dirname, 'dist'), |
||||
publicPath: '/' |
||||
}, |
||||
module: { |
||||
rules: [ |
||||
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" } |
||||
] |
||||
}, |
||||
stats: "normal", |
||||
devServer: { |
||||
contentBase: path.join(__dirname, "dist"), |
||||
publicPath: '/', |
||||
//inline: true,
|
||||
hot: true, |
||||
host: '0.0.0.0', |
||||
disableHostCheck: true |
||||
}, |
||||
}; |
Loading…
Reference in new issue