webpack-dev-server 1.16.1 → 1.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/bin/webpack-dev-server.js +152 -128
- package/client/index.bundle.js +3 -3
- package/client/index.js +131 -128
- package/client/live.bundle.js +6 -6
- package/client/live.html +1 -1
- package/client/live.js +129 -129
- package/client/page.jade +7 -7
- package/client/socket.js +41 -41
- package/client/sockjs.bundle.js +1 -0
- package/client/style.css +58 -58
- package/client/web_modules/jquery/index.js +1 -1
- package/client/web_modules/jquery/jquery-1.8.1.js +9301 -9301
- package/client/webpack.config.js +11 -11
- package/lib/Server.js +458 -414
- package/package.json +2 -2
- package/ssl/ca.crt +13 -13
- package/ssl/ca.csr +11 -11
- package/ssl/ca.key +15 -15
- package/ssl/server.crt +13 -13
- package/ssl/server.csr +11 -11
- package/ssl/server.key +15 -15
- package/CHANGELOG.md +0 -36
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# webpack-dev-server
|
|
2
|
+
|
|
3
|
+
**THIS SERVER SHOULD BE USED FOR DEVELOPMENT ONLY!**
|
|
4
|
+
|
|
5
|
+
**DO NOT USE IT IN PRODUCTION!**
|
|
6
|
+
|
|
7
|
+
It's a live reloading server for [webpack](http://webpack.github.io).
|
|
8
|
+
|
|
9
|
+
# [Documentation](http://webpack.github.io/docs/webpack-dev-server.html)
|
|
10
|
+
|
|
11
|
+
## Inspiration
|
|
12
|
+
|
|
13
|
+
This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/nof5).
|
|
14
|
+
|
|
15
|
+
## Contributing
|
|
16
|
+
|
|
17
|
+
The client scripts are built with `npm run-script prepublish`.
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
Copyright 2012-2014 Tobias Koppers
|
|
22
|
+
|
|
23
|
+
[MIT](http://www.opensource.org/licenses/mit-license.php)
|
|
@@ -18,44 +18,48 @@ var webpack = require("webpack");
|
|
|
18
18
|
|
|
19
19
|
var optimist = require("optimist")
|
|
20
20
|
|
|
21
|
-
.usage("webpack-dev-server " + require("../package.json").version + "\n" +
|
|
22
|
-
|
|
21
|
+
.usage("webpack-dev-server " + require("../package.json").version + "\n" +
|
|
22
|
+
"Usage: http://webpack.github.io/docs/webpack-dev-server.html")
|
|
23
23
|
|
|
24
|
-
.boolean("lazy").describe("lazy")
|
|
24
|
+
.boolean("lazy").describe("lazy")
|
|
25
25
|
|
|
26
|
-
.boolean("stdin").describe("stdin", "close when stdin ends")
|
|
26
|
+
.boolean("stdin").describe("stdin", "close when stdin ends")
|
|
27
27
|
|
|
28
|
-
.boolean("info").describe("info").default("info", true)
|
|
28
|
+
.boolean("info").describe("info").default("info", true)
|
|
29
29
|
|
|
30
|
-
.boolean("quiet").describe("quiet")
|
|
30
|
+
.boolean("quiet").describe("quiet")
|
|
31
31
|
|
|
32
|
-
.boolean("inline").describe("inline", "Inline the webpack-dev-server logic into the bundle.")
|
|
32
|
+
.boolean("inline").describe("inline", "Inline the webpack-dev-server logic into the bundle.")
|
|
33
33
|
|
|
34
|
-
.boolean("https").describe("https")
|
|
34
|
+
.boolean("https").describe("https")
|
|
35
35
|
|
|
36
|
-
.string("key").describe("key", "Path to a SSL key.")
|
|
36
|
+
.string("key").describe("key", "Path to a SSL key.")
|
|
37
37
|
|
|
38
|
-
.string("cert").describe("cert", "Path to a SSL certificate.")
|
|
38
|
+
.string("cert").describe("cert", "Path to a SSL certificate.")
|
|
39
39
|
|
|
40
|
-
.string("cacert").describe("cacert", "Path to a SSL CA certificate.")
|
|
40
|
+
.string("cacert").describe("cacert", "Path to a SSL CA certificate.")
|
|
41
41
|
|
|
42
|
-
.string("
|
|
42
|
+
.string("pfx").describe("pfx", "Path to a SSL pfx file.")
|
|
43
43
|
|
|
44
|
-
.string("
|
|
44
|
+
.string("pfx-passphrase").describe("pfx-passphrase", "Passphrase for pfx file.")
|
|
45
45
|
|
|
46
|
-
.
|
|
46
|
+
.string("content-base").describe("content-base", "A directory or URL to serve HTML content from.")
|
|
47
47
|
|
|
48
|
-
.string("
|
|
48
|
+
.string("content-base-target").describe("content-base-target", "Proxy requests to this target.")
|
|
49
49
|
|
|
50
|
-
.boolean("
|
|
50
|
+
.boolean("history-api-fallback").describe("history-api-fallback", "Fallback to /index.html for Single Page Applications.")
|
|
51
51
|
|
|
52
|
-
.
|
|
52
|
+
.string("client-log-level").describe("client-log-level", "Log level in the browser (info, warning, error or none)").default("client-log-level", "info")
|
|
53
53
|
|
|
54
|
-
.
|
|
54
|
+
.boolean("compress").describe("compress", "enable gzip compression")
|
|
55
55
|
|
|
56
|
-
.describe("
|
|
56
|
+
.boolean("open").describe("open", "Open default browser")
|
|
57
57
|
|
|
58
|
-
.describe("
|
|
58
|
+
.describe("port", "The port").default("port", 8080)
|
|
59
|
+
|
|
60
|
+
.describe("public", "The public hostname/ip address of the server")
|
|
61
|
+
|
|
62
|
+
.describe("host", "The hostname/ip address the server will bind to").default("host", "localhost");
|
|
59
63
|
|
|
60
64
|
require("webpack/bin/config-optimist")(optimist);
|
|
61
65
|
|
|
@@ -64,141 +68,161 @@ var argv = optimist.argv;
|
|
|
64
68
|
var wpOpt = require("webpack/bin/convert-argv")(optimist, argv, {
|
|
65
69
|
outputFilename: "/bundle.js"
|
|
66
70
|
});
|
|
67
|
-
var firstWpOpt = Array.isArray(wpOpt) ? wpOpt[0] : wpOpt;
|
|
68
71
|
|
|
69
|
-
|
|
72
|
+
function processOptions(wpOpt) {
|
|
73
|
+
//process Promise
|
|
74
|
+
if(typeof wpOpt.then === "function") {
|
|
75
|
+
wpOpt.then(processOptions).catch(function(err) {
|
|
76
|
+
console.error(err.stack || err);
|
|
77
|
+
process.exit(); // eslint-disable-line
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
70
81
|
|
|
71
|
-
|
|
72
|
-
options.host = argv.host;
|
|
82
|
+
var firstWpOpt = Array.isArray(wpOpt) ? wpOpt[0] : wpOpt;
|
|
73
83
|
|
|
74
|
-
|
|
75
|
-
options.public = argv.public;
|
|
84
|
+
var options = wpOpt.devServer || firstWpOpt.devServer || {};
|
|
76
85
|
|
|
77
|
-
if(argv.
|
|
78
|
-
|
|
86
|
+
if(argv.host !== "localhost" || !options.host)
|
|
87
|
+
options.host = argv.host;
|
|
79
88
|
|
|
80
|
-
if(
|
|
81
|
-
|
|
82
|
-
if(!/^(https?:)?\/\//.test(options.publicPath) && options.publicPath[0] !== "/")
|
|
83
|
-
options.publicPath = "/" + options.publicPath;
|
|
84
|
-
}
|
|
89
|
+
if(argv.public)
|
|
90
|
+
options.public = argv.public;
|
|
85
91
|
|
|
86
|
-
if(!options.
|
|
87
|
-
|
|
88
|
-
if(!options.filename)
|
|
89
|
-
options.filename = firstWpOpt.output && firstWpOpt.output.filename;
|
|
90
|
-
[].concat(wpOpt).forEach(function(wpOpt) {
|
|
91
|
-
wpOpt.output.path = "/";
|
|
92
|
-
});
|
|
92
|
+
if(argv.port !== 8080 || !options.port)
|
|
93
|
+
options.port = argv.port;
|
|
93
94
|
|
|
94
|
-
if(!options.
|
|
95
|
-
|
|
95
|
+
if(!options.publicPath) {
|
|
96
|
+
options.publicPath = firstWpOpt.output && firstWpOpt.output.publicPath || "";
|
|
97
|
+
if(!/^(https?:)?\/\//.test(options.publicPath) && options.publicPath[0] !== "/")
|
|
98
|
+
options.publicPath = "/" + options.publicPath;
|
|
99
|
+
}
|
|
96
100
|
|
|
97
|
-
if(
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
if(!options.outputPath)
|
|
102
|
+
options.outputPath = "/";
|
|
103
|
+
if(!options.filename)
|
|
104
|
+
options.filename = firstWpOpt.output && firstWpOpt.output.filename;
|
|
105
|
+
[].concat(wpOpt).forEach(function(wpOpt) {
|
|
106
|
+
wpOpt.output.path = "/";
|
|
100
107
|
});
|
|
101
|
-
process.stdin.resume();
|
|
102
|
-
}
|
|
103
108
|
|
|
104
|
-
if(!options.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if(!options.hot)
|
|
108
|
-
options.hot = argv["hot"];
|
|
109
|
-
|
|
110
|
-
if(argv["content-base"]) {
|
|
111
|
-
options.contentBase = argv["content-base"];
|
|
112
|
-
if(/^[0-9]$/.test(options.contentBase))
|
|
113
|
-
options.contentBase = +options.contentBase;
|
|
114
|
-
else if(!/^(https?:)?\/\//.test(options.contentBase))
|
|
115
|
-
options.contentBase = path.resolve(options.contentBase);
|
|
116
|
-
} else if(argv["content-base-target"]) {
|
|
117
|
-
options.contentBase = {
|
|
118
|
-
target: argv["content-base-target"]
|
|
119
|
-
};
|
|
120
|
-
} else if(!options.contentBase) {
|
|
121
|
-
options.contentBase = process.cwd();
|
|
122
|
-
}
|
|
109
|
+
if(!options.watchOptions)
|
|
110
|
+
options.watchOptions = firstWpOpt.watchOptions;
|
|
123
111
|
|
|
124
|
-
if(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
112
|
+
if(argv["stdin"]) {
|
|
113
|
+
process.stdin.on('end', function() {
|
|
114
|
+
process.exit(0); // eslint-disable-line no-process-exit
|
|
115
|
+
});
|
|
116
|
+
process.stdin.resume();
|
|
117
|
+
}
|
|
130
118
|
|
|
131
|
-
if(
|
|
132
|
-
|
|
119
|
+
if(!options.watchDelay && !options.watchOptions) // TODO remove in next major version
|
|
120
|
+
options.watchDelay = firstWpOpt.watchDelay;
|
|
121
|
+
|
|
122
|
+
if(!options.hot)
|
|
123
|
+
options.hot = argv["hot"];
|
|
124
|
+
|
|
125
|
+
if(argv["content-base"]) {
|
|
126
|
+
options.contentBase = argv["content-base"];
|
|
127
|
+
if(/^[0-9]$/.test(options.contentBase))
|
|
128
|
+
options.contentBase = +options.contentBase;
|
|
129
|
+
else if(!/^(https?:)?\/\//.test(options.contentBase))
|
|
130
|
+
options.contentBase = path.resolve(options.contentBase);
|
|
131
|
+
} else if(argv["content-base-target"]) {
|
|
132
|
+
options.contentBase = {
|
|
133
|
+
target: argv["content-base-target"]
|
|
134
|
+
};
|
|
135
|
+
} else if(!options.contentBase) {
|
|
136
|
+
options.contentBase = process.cwd();
|
|
137
|
+
}
|
|
133
138
|
|
|
134
|
-
if(
|
|
135
|
-
|
|
139
|
+
if(!options.stats) {
|
|
140
|
+
options.stats = {
|
|
141
|
+
cached: false,
|
|
142
|
+
cachedAssets: false
|
|
143
|
+
};
|
|
144
|
+
}
|
|
136
145
|
|
|
137
|
-
if(
|
|
138
|
-
|
|
146
|
+
if(typeof options.stats === "object" && typeof options.stats.colors === "undefined")
|
|
147
|
+
options.stats.colors = require("supports-color");
|
|
139
148
|
|
|
140
|
-
if(argv["
|
|
141
|
-
|
|
149
|
+
if(argv["lazy"])
|
|
150
|
+
options.lazy = true;
|
|
142
151
|
|
|
143
|
-
if(argv["
|
|
144
|
-
|
|
152
|
+
if(!argv["info"])
|
|
153
|
+
options.noInfo = true;
|
|
145
154
|
|
|
146
|
-
if(argv["
|
|
147
|
-
|
|
155
|
+
if(argv["quiet"])
|
|
156
|
+
options.quiet = true;
|
|
148
157
|
|
|
149
|
-
if(argv["
|
|
150
|
-
|
|
158
|
+
if(argv["https"])
|
|
159
|
+
options.https = true;
|
|
151
160
|
|
|
152
|
-
if(argv["
|
|
153
|
-
|
|
161
|
+
if(argv["cert"])
|
|
162
|
+
options.cert = fs.readFileSync(path.resolve(argv["cert"]));
|
|
154
163
|
|
|
155
|
-
if(argv["
|
|
156
|
-
|
|
164
|
+
if(argv["key"])
|
|
165
|
+
options.key = fs.readFileSync(path.resolve(argv["key"]));
|
|
157
166
|
|
|
158
|
-
if(argv["
|
|
159
|
-
|
|
167
|
+
if(argv["cacert"])
|
|
168
|
+
options.ca = fs.readFileSync(path.resolve(argv["cacert"]));
|
|
160
169
|
|
|
161
|
-
if(argv["
|
|
162
|
-
|
|
170
|
+
if(argv["pfx"])
|
|
171
|
+
options.pfx = fs.readFileSync(path.resolve(argv["pfx"]));
|
|
163
172
|
|
|
164
|
-
if(argv["
|
|
165
|
-
|
|
173
|
+
if(argv["pfx-passphrase"])
|
|
174
|
+
options.pfxPassphrase = argv["pfx-passphrase"];
|
|
166
175
|
|
|
167
|
-
if(argv["
|
|
168
|
-
|
|
176
|
+
if(argv["inline"])
|
|
177
|
+
options.inline = true;
|
|
169
178
|
|
|
170
|
-
|
|
179
|
+
if(argv["history-api-fallback"])
|
|
180
|
+
options.historyApiFallback = true;
|
|
171
181
|
|
|
172
|
-
if(
|
|
173
|
-
|
|
182
|
+
if(argv["client-log-level"])
|
|
183
|
+
options.clientLogLevel = argv["client-log-level"];
|
|
174
184
|
|
|
175
|
-
if(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
if(argv["compress"])
|
|
186
|
+
options.compress = true;
|
|
187
|
+
|
|
188
|
+
if(argv["open"])
|
|
189
|
+
options.open = true;
|
|
190
|
+
|
|
191
|
+
var protocol = options.https ? "https" : "http";
|
|
192
|
+
|
|
193
|
+
if(options.inline) {
|
|
194
|
+
var devClient = [require.resolve("../client/") + "?" + protocol + "://" + (options.public || (options.host + ":" + options.port))];
|
|
195
|
+
|
|
196
|
+
if(options.hot)
|
|
197
|
+
devClient.push("webpack/hot/dev-server");
|
|
198
|
+
[].concat(wpOpt).forEach(function(wpOpt) {
|
|
199
|
+
if(typeof wpOpt.entry === "object" && !Array.isArray(wpOpt.entry)) {
|
|
200
|
+
Object.keys(wpOpt.entry).forEach(function(key) {
|
|
201
|
+
wpOpt.entry[key] = devClient.concat(wpOpt.entry[key]);
|
|
202
|
+
});
|
|
203
|
+
} else {
|
|
204
|
+
wpOpt.entry = devClient.concat(wpOpt.entry);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
new Server(webpack(wpOpt), options).listen(options.port, options.host, function(err) {
|
|
210
|
+
var uri = protocol + "://" + options.host + ":" + options.port + "/";
|
|
211
|
+
if(!options.inline)
|
|
212
|
+
uri += "webpack-dev-server/";
|
|
213
|
+
|
|
214
|
+
if(err) throw err;
|
|
215
|
+
console.log(" " + uri);
|
|
216
|
+
console.log("webpack result is served from " + options.publicPath);
|
|
217
|
+
if(typeof options.contentBase === "object")
|
|
218
|
+
console.log("requests are proxied to " + options.contentBase.target);
|
|
219
|
+
else
|
|
220
|
+
console.log("content is served from " + options.contentBase);
|
|
221
|
+
if(options.historyApiFallback)
|
|
222
|
+
console.log("404s will fallback to %s", options.historyApiFallback.index || "/index.html");
|
|
223
|
+
if(options.open)
|
|
224
|
+
open(uri);
|
|
185
225
|
});
|
|
186
226
|
}
|
|
187
227
|
|
|
188
|
-
|
|
189
|
-
var uri = protocol + "://" + options.host + ":" + options.port + "/";
|
|
190
|
-
if(!options.inline)
|
|
191
|
-
uri += "webpack-dev-server/";
|
|
192
|
-
|
|
193
|
-
if(err) throw err;
|
|
194
|
-
console.log(" " + uri);
|
|
195
|
-
console.log("webpack result is served from " + options.publicPath);
|
|
196
|
-
if(typeof options.contentBase === "object")
|
|
197
|
-
console.log("requests are proxied to " + options.contentBase.target);
|
|
198
|
-
else
|
|
199
|
-
console.log("content is served from " + options.contentBase);
|
|
200
|
-
if(options.historyApiFallback)
|
|
201
|
-
console.log("404s will fallback to %s", options.historyApiFallback.index || "/index.html");
|
|
202
|
-
if(options.open)
|
|
203
|
-
open(uri);
|
|
204
|
-
});
|
|
228
|
+
processOptions(wpOpt);
|