Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed part 4 #15

Open
wants to merge 1 commit into
base: part-4-start
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { Component } from 'react'
class App extends Component {

render() {
return <div>This is definitely a React app now!</div>
return <div>This is definitely a hot (module reloading) React app now!</div>
}

}
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A simple todo list app built with React, Redux and Webpack",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"serve": "nodemon server/server.js"
"serve": "nodemon server/server.js --ignore components"
},
"repository": {
"type": "git",
Expand All @@ -17,9 +17,12 @@
"babel-loader": "^6.2.2",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-react-hmre": "^1.1.1",
"express": "^4.13.4",
"react": "^0.14.7",
"react-dom": "^0.14.7",
"webpack": "^1.12.13"
"webpack": "^1.12.13",
"webpack-dev-middleware": "^1.10.1",
"webpack-hot-middleware": "^2.17.0"
}
}
13 changes: 13 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
var express = require('express');
var path = require('path');
var config = require('../webpack.config.js');
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');

var app = express();

var compiler = webpack(config);

app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));

app.use(webpackHotMiddleware(compiler));

app.use(express.static('./dist'));

app.use('/', function (req, res) {
Expand Down
16 changes: 13 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
var webpack = require('webpack');

module.exports = {
devtool: 'inline-source-map',
entry: ['./client/client.js'],
entry: [
'webpack-hot-middleware/client',
'./client/client.js'
],
output: {
path: './dist',
path: require("path").resolve("./dist"),
filename: 'bundle.js',
publicPath: '/'
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015']
presets: ['react', 'es2015', 'react-hmre']
}
}
]
Expand Down