Skip to content

Commit 8160f08

Browse files
committed
Add HTML Reload
1 parent 69b4880 commit 8160f08

File tree

6 files changed

+52
-24
lines changed

6 files changed

+52
-24
lines changed

app/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
5+
<title>get shit done =)</title>
6+
</head>
7+
<body>
8+
9+
</body>
10+
</html>

app/index.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// Entry point with ES6 support
22
// Happy Coding!
3-
'use strict';
4-
5-
const webpackReadyDebugMessage = '%cbundle ready, happy coding :)...';
6-
console.log(webpackReadyDebugMessage, "color: #ddd;font-style: italic;}");
3+
/* @jsx h*/
4+
module.hot.accept();
5+
const $ = require('jquery');
6+
$.fn.red = function() {
7+
return this.each(function () {
8+
$(this).css({
9+
color: 'blue'
10+
});
11+
})
12+
}

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
},
1010
"author": "kmilov <[email protected]>",
1111
"devDependencies": {
12+
"axios": "^0.15.2",
1213
"babel-core": "^6.1.2",
1314
"babel-loader": "^6.1.0",
15+
"babel-preset-es2015": "^6.14.0",
16+
"babel-preset-react": "^6.11.1",
17+
"html-webpack-plugin": "^2.26.0",
18+
"jquery": "^3.1.1",
19+
"reload-html-webpack-plugin": "^0.1.2",
1420
"webpack": "^1.12.4",
1521
"webpack-dev-server": "^1.12.1"
1622
}

public/index.html

-11
This file was deleted.

server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var bundler = new webpackDevServer(compiler, {
2121

2222
// Webpack Dev Server takes this path to save the output file
2323
publicPath: '/',
24-
24+
2525
hot: true,
2626
quite: false,
2727
noInfo: false,
@@ -30,6 +30,6 @@ var bundler = new webpackDevServer(compiler, {
3030
}
3131
})
3232

33-
bundler.listen(8080, 'localhost', function() {
33+
bundler.listen(3000, 'localhost', function() {
3434
console.log("Bundling project, please wait...");
3535
})

webpack.config.js

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
11
var webpack = require('webpack');
22
var path = require('path');
33

4+
const HtmlWebpackPlugin = require('html-webpack-plugin');
5+
var ReloadPlugin = require('reload-html-webpack-plugin');
6+
const HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
7+
template: 'app/index.html',
8+
inject: 'body'
9+
});
10+
411
module.exports = {
512
devtool: 'eval',
613

714
entry: [
815
'webpack/hot/dev-server',
9-
'webpack-dev-server/client?http://localhost:8080',
16+
'webpack-dev-server/client?http://localhost:3000',
1017
path.resolve(__dirname, 'app', 'index.js')
1118
],
1219

1320
output: {
1421
path: path.resolve(__dirname, 'public'),
1522
filename: 'bundle.js',
16-
23+
1724
// We need to give Webpack a path. It does not actually need it,
1825
// because files are kept in memory in webpack-dev-server, but an
1926
// error will occur if nothing is specified.
20-
publicPath: path.resolve(__dirname, 'public')
27+
publicPath: '/'
2128
},
2229

23-
modules: {
30+
module: {
2431
loaders: [
25-
{test: /\.html$/, loader: 'babel-lader', exclude: [path.resolve(__dirname,'node_modules')]},
26-
{test: /\.css$/, loader: 'style!css'}
32+
{
33+
test: /\.jsx?$/,
34+
exclude: [path.resolve(__dirname,'node_modules')],
35+
loader: 'babel-loader',
36+
query: {
37+
presets: ['es2015', 'react'],
38+
}
39+
}
2740
]
2841
},
2942

30-
plugins: [new webpack.HotModuleReplacementPlugin()]
43+
plugins: [
44+
new webpack.HotModuleReplacementPlugin(),
45+
HTMLWebpackPluginConfig,
46+
new ReloadPlugin()
47+
]
3148

3249
}

0 commit comments

Comments
 (0)