Skip to content

Commit a597167

Browse files
committed
added deprecation warnings for contentBase
1 parent 675b62b commit a597167

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Server.js

+8
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,31 @@ function Server(compiler, options) {
130130
var contentBase = options.contentBase || process.cwd();
131131

132132
if(typeof contentBase === "object") {
133+
console.log('Using contentBase as a proxy is deprecated and will be removed in the next major version. Please use the proxy option instead.\n\nTo update remove the contentBase option from webpack.config.js and add this:');
134+
console.log('proxy: {\n\t"*": [your current contentBase configuration]\n}');
133135
// Proxy every request to contentBase.target
134136
app.all("*", function(req, res) {
135137
proxy.web(req, res, contentBase, function(err) {
136138
var msg = "cannot proxy to " + contentBase.target + " (" + err.message + ")";
137139
this.io.sockets.emit("proxy-error", [msg]);
138140
}.bind(this));
139141
}.bind(this));
142+
140143
} else if(/^(https?:)?\/\//.test(contentBase)) {
144+
console.log('Using contentBase as a proxy is deprecated and will be removed in the next major version. Please use the proxy option instead.\n\nTo update remove the contentBase option from webpack.config.js and add this:');
145+
console.log('proxy: {\n\t"*": "'+contentBase+'"\n}');
141146
// Redirect every request to contentBase
142147
app.get("*", function(req, res) {
143148
res.writeHead(302, {
144149
'Location': contentBase + req.path + (req._parsedUrl.search || "")
145150
});
146151
res.end();
147152
}.bind(this));
153+
148154
} else if(typeof contentBase === "number") {
149155
// Redirect every request to the port contentBase
156+
console.log('Using contentBase as a proxy is deprecated and will be removed in the next major version. Please use the proxy option instead.\n\nTo update remove the contentBase option from webpack.config.js and add this:');
157+
console.log('proxy: {\n\t"*": "http://localhost:'+contentBase+'"\n}');
150158
app.get("*", function(req, res) {
151159
res.writeHead(302, {
152160
'Location': "//localhost:" + contentBase + req.path + (req._parsedUrl.search || "")

0 commit comments

Comments
 (0)