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

Commit

Permalink
Fix double slashes in file-loader URLs and fix client-side HMR.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick committed Feb 23, 2016
1 parent 42b50f2 commit d2cb263
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
35 changes: 19 additions & 16 deletions configs/webpack.client-watch.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
var webpack = require("webpack");
var config = require("./webpack.client.js");
var hostname = process.env.HOSTNAME || "localhost";
var port = 8080;
var wds = {
hostname: process.env.HOSTNAME || "localhost",
port: 8080
};

config.cache = true;
config.debug = true;
config.devtool = "cheap-module-eval-source-map";

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

config.output.hotUpdateMainFilename = "update/[hash]/update.json";
config.devServer = {
publicPath: "http://" + wds.hostname + ":" + wds.port + "/dist",
hot: true,
inline: false,
lazy: false,
quiet: true,
noInfo: true,
headers: {"Access-Control-Allow-Origin": "*"},
stats: {colors: true},
host: wds.hostname
};

config.output.publicPath = config.devServer.publicPath;
config.output.hotUpdateMainFilename = "update/[hash]/update.json";
config.output.hotUpdateChunkFilename = "update/[hash]/[id].update.js";

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

config.devServer = {
publicPath: "http://" + hostname + ":" + port + "/dist/",
hot: true,
inline: false,
lazy: false,
quiet: true,
noInfo: true,
headers: {"Access-Control-Allow-Origin": "*"},
stats: {colors: true},
host: hostname
};

module.exports = config;
2 changes: 1 addition & 1 deletion configs/webpack.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
module: {
loaders: [
{test: /\.json$/, loaders: ["json"]},
{test: /\.(ico|gif|png|jpg|jpeg|svg|webp)$/, loaders: ["file?context=static&name=/[path][name].[ext]"]}
{test: /\.(ico|gif|png|jpg|jpeg|svg|webp)$/, loaders: ["file?context=static&name=/[path][name].[ext]"], exclude: /node_modules/}
],
postLoaders: [
{test: /\.js$/, loaders: ["babel?presets[]=es2015&presets[]=stage-0&presets[]=react"], exclude: /node_modules/}
Expand Down
10 changes: 8 additions & 2 deletions configs/webpack.server-watch.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
var webpack = require("webpack");
var config = require("./webpack.server.js");
var wds = {
hostname: process.env.HOSTNAME || "localhost",
port: 8080
};

config.cache = true;
config.debug = true;
config.cache = true;
config.debug = true;

config.entry.unshift(
"webpack/hot/poll?1000"
);

config.output.publicPath = "http://" + wds.hostname + ":" + wds.port + "/dist";

config.plugins = [
new webpack.DefinePlugin({__CLIENT__: false, __SERVER__: true, __PRODUCTION__: false, __DEV__: true}),
new webpack.HotModuleReplacementPlugin(),
Expand Down
4 changes: 2 additions & 2 deletions configs/webpack.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ module.exports = {
module: {
loaders: [
{test: /\.json$/, loaders: ["json"]},
{test: /\.(ico|gif|png|jpg|jpeg|svg|webp)$/, loaders: ["file?context=static&name=/[path][name].[ext]"]}
{test: /\.(ico|gif|png|jpg|jpeg|svg|webp)$/, loaders: ["file?context=static&name=/[path][name].[ext]"], exclude: /node_modules/},
{test: /\.js$/, loaders: ["babel?presets[]=es2015&presets[]=stage-0&presets[]=react"], exclude: /node_modules/}
],
postLoaders: [
{test: /\.js$/, loaders: ["babel?presets[]=es2015&presets[]=stage-0&presets[]=react"], exclude: /node_modules/}
],
noParse: /\.min\.js/
},
Expand Down

0 comments on commit d2cb263

Please sign in to comment.