-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 180a90a
Showing
15 changed files
with
3,438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"presets": [ | ||
["es2015", { "modules": false }], | ||
"react" | ||
], | ||
"plugins": [ | ||
"react-hot-loader/babel", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
|
||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dist | ||
/node_modules | ||
|
||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="/static/vendor.js"></script> | ||
<script src="/static/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"restartable": "rs", | ||
"ignore": [ | ||
".git", | ||
"node_modules/**/node_modules" | ||
], | ||
"verbose": true, | ||
"watch": [ | ||
"server.js" | ||
], | ||
"env": { | ||
"NODE_ENV": "development" | ||
}, | ||
"ext": "js json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"scripts": { | ||
"dev": "nodemon server.js" | ||
}, | ||
"dependencies": { | ||
"babel-core": "^6.24.1", | ||
"babel-loader": "^7.0.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-preset-react": "^6.24.1", | ||
"body-parser": "^1.17.2", | ||
"express": "^4.15.3", | ||
"nodemon": "^1.11.0", | ||
"react": "^15.5.4", | ||
"react-dom": "^15.5.4", | ||
"react-hot-loader": "3.0.0-beta.7", | ||
"react-router": "3.0.5", | ||
"webpack": "^2.6.1", | ||
"webpack-dev-middleware": "^1.10.2", | ||
"webpack-hot-middleware": "^2.18.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## react-router-hmr-case | ||
|
||
How to make react router v3 works with react-hot-loader | ||
|
||
`npm run dev` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const express = require('express'); | ||
const { resolve } = require('path'); | ||
const bodyParser = require('body-parser'); | ||
|
||
const app = new express(); | ||
const PORT = process.env.PORT || 3000; | ||
const ENV = process.env.NODE_ENV; | ||
|
||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.use(bodyParser.json()); | ||
|
||
const webpack = require('webpack'); | ||
const webpackDevMiddleware = require('webpack-dev-middleware'); | ||
const webpackHotMiddleware = require('webpack-hot-middleware'); | ||
const webpackConfig = require('./webpack.config'); | ||
|
||
const compiler = webpack(webpackConfig); | ||
|
||
app.use(webpackDevMiddleware(compiler, { | ||
hot: true, | ||
publicPath: webpackConfig.output.publicPath, | ||
inline: true, | ||
noInfo: true, | ||
})); | ||
app.use(webpackHotMiddleware(compiler)); | ||
|
||
app.use(express.static(resolve(__dirname, '../dist'))); | ||
app.use('/', (req, res) => { | ||
res | ||
.sendFile(resolve(__dirname, 'index.html')); | ||
}); | ||
|
||
// Run server | ||
app.listen(PORT, () => { | ||
// eslint-disable-next-line no-console | ||
console.log(`running on http://localhost:${PORT} in ${ENV} enviroment `); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router'; | ||
|
||
class App extends React.Component { | ||
render() { | ||
const { children } = this.props; | ||
|
||
return ( | ||
<div> | ||
<Link to='/'>Home</Link> | <Link to='/about'>About</Link> | ||
<br /> | ||
{children} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { AppContainer } from 'react-hot-loader'; | ||
import { match, Router, browserHistory } from 'react-router'; | ||
|
||
import App from './App'; | ||
import routes from './routes'; | ||
|
||
const mountNode = document.getElementById('root'); | ||
|
||
const render = () => { | ||
match({ | ||
history: browserHistory, | ||
routes, | ||
}, (error, redirectLocation, renderProps) => { | ||
ReactDOM.render( | ||
<AppContainer> | ||
<Router {...renderProps} /> | ||
</AppContainer>, | ||
mountNode, | ||
); | ||
}); | ||
}; | ||
|
||
render(); | ||
|
||
if (module.hot) { | ||
module.hot.accept('./App', render); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
export default () => ( | ||
<div className="about-page"> | ||
About | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
export default () => ( | ||
<div className="home-page"> | ||
Home | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { Route, IndexRoute } from 'react-router'; | ||
|
||
import App from './App'; | ||
import Home from './pages/Home'; | ||
import About from './pages/About'; | ||
|
||
export default ( | ||
<Route path="/" component={App}> | ||
<IndexRoute component={Home} /> | ||
<Route path="about" component={About} /> | ||
</Route> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const webpack = require('webpack'); | ||
const { join, resolve } = require('path'); | ||
|
||
module.exports = { | ||
entry: { | ||
app: [ | ||
'react-hot-loader/patch', | ||
'webpack-hot-middleware/client', | ||
resolve(__dirname, './src/index.js'), | ||
], | ||
vendor: [ | ||
'react', | ||
'react-dom', | ||
'react-router', | ||
], | ||
}, | ||
output: { | ||
path: resolve(__dirname, 'dist'), | ||
publicPath: '/static/', | ||
filename: '[name].js', | ||
}, | ||
context: resolve(__dirname, 'src'), | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
use: 'babel-loader', | ||
include: join(__dirname, 'src'), | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.NoEmitOnErrorsPlugin(), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'vendor', | ||
minChunks: Infinity, | ||
filename: 'vendor.js', | ||
}), | ||
], | ||
}; |
Oops, something went wrong.