Skip to content
This repository was archived by the owner on Jan 11, 2019. It is now read-only.

Commit d2cb263

Browse files
author
Rick
committed
Fix double slashes in file-loader URLs and fix client-side HMR.
1 parent 42b50f2 commit d2cb263

File tree

4 files changed

+30
-21
lines changed

4 files changed

+30
-21
lines changed

configs/webpack.client-watch.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
var webpack = require("webpack");
22
var config = require("./webpack.client.js");
3-
var hostname = process.env.HOSTNAME || "localhost";
4-
var port = 8080;
3+
var wds = {
4+
hostname: process.env.HOSTNAME || "localhost",
5+
port: 8080
6+
};
57

68
config.cache = true;
79
config.debug = true;
810
config.devtool = "cheap-module-eval-source-map";
911

1012
config.entry.unshift(
11-
"webpack-dev-server/client?http://" + hostname + ":" + port,
13+
"webpack-dev-server/client?http://" + wds.hostname + ":" + wds.port,
1214
"webpack/hot/only-dev-server"
1315
);
1416

15-
config.output.hotUpdateMainFilename = "update/[hash]/update.json";
17+
config.devServer = {
18+
publicPath: "http://" + wds.hostname + ":" + wds.port + "/dist",
19+
hot: true,
20+
inline: false,
21+
lazy: false,
22+
quiet: true,
23+
noInfo: true,
24+
headers: {"Access-Control-Allow-Origin": "*"},
25+
stats: {colors: true},
26+
host: wds.hostname
27+
};
28+
29+
config.output.publicPath = config.devServer.publicPath;
30+
config.output.hotUpdateMainFilename = "update/[hash]/update.json";
1631
config.output.hotUpdateChunkFilename = "update/[hash]/[id].update.js";
1732

1833
config.plugins = [
@@ -25,16 +40,4 @@ config.module.postLoaders = [
2540
{test: /\.js$/, loaders: ["babel?cacheDirectory&presets[]=es2015&presets[]=stage-0&presets[]=react&presets[]=react-hmre"], exclude: /node_modules/}
2641
];
2742

28-
config.devServer = {
29-
publicPath: "http://" + hostname + ":" + port + "/dist/",
30-
hot: true,
31-
inline: false,
32-
lazy: false,
33-
quiet: true,
34-
noInfo: true,
35-
headers: {"Access-Control-Allow-Origin": "*"},
36-
stats: {colors: true},
37-
host: hostname
38-
};
39-
4043
module.exports = config;

configs/webpack.client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
module: {
2424
loaders: [
2525
{test: /\.json$/, loaders: ["json"]},
26-
{test: /\.(ico|gif|png|jpg|jpeg|svg|webp)$/, loaders: ["file?context=static&name=/[path][name].[ext]"]}
26+
{test: /\.(ico|gif|png|jpg|jpeg|svg|webp)$/, loaders: ["file?context=static&name=/[path][name].[ext]"], exclude: /node_modules/}
2727
],
2828
postLoaders: [
2929
{test: /\.js$/, loaders: ["babel?presets[]=es2015&presets[]=stage-0&presets[]=react"], exclude: /node_modules/}

configs/webpack.server-watch.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
var webpack = require("webpack");
22
var config = require("./webpack.server.js");
3+
var wds = {
4+
hostname: process.env.HOSTNAME || "localhost",
5+
port: 8080
6+
};
37

4-
config.cache = true;
5-
config.debug = true;
8+
config.cache = true;
9+
config.debug = true;
610

711
config.entry.unshift(
812
"webpack/hot/poll?1000"
913
);
1014

15+
config.output.publicPath = "http://" + wds.hostname + ":" + wds.port + "/dist";
16+
1117
config.plugins = [
1218
new webpack.DefinePlugin({__CLIENT__: false, __SERVER__: true, __PRODUCTION__: false, __DEV__: true}),
1319
new webpack.HotModuleReplacementPlugin(),

configs/webpack.server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ module.exports = {
2121
module: {
2222
loaders: [
2323
{test: /\.json$/, loaders: ["json"]},
24-
{test: /\.(ico|gif|png|jpg|jpeg|svg|webp)$/, loaders: ["file?context=static&name=/[path][name].[ext]"]}
24+
{test: /\.(ico|gif|png|jpg|jpeg|svg|webp)$/, loaders: ["file?context=static&name=/[path][name].[ext]"], exclude: /node_modules/},
25+
{test: /\.js$/, loaders: ["babel?presets[]=es2015&presets[]=stage-0&presets[]=react"], exclude: /node_modules/}
2526
],
2627
postLoaders: [
27-
{test: /\.js$/, loaders: ["babel?presets[]=es2015&presets[]=stage-0&presets[]=react"], exclude: /node_modules/}
2828
],
2929
noParse: /\.min\.js/
3030
},

0 commit comments

Comments
 (0)