@@ -221,6 +221,23 @@ function addMiddleware(devServer) {
221
221
222
222
function runDevServer ( port ) {
223
223
var devServer = new WebpackDevServer ( compiler , {
224
+ // By default WebpackDevServer also serves files from the current directory.
225
+ // This might be useful in legacy apps. However we already encourage people
226
+ // to use Webpack for importing assets in the code, so we don't need to
227
+ // additionally serve files by their filenames. Otherwise, even if it
228
+ // works in development, those files will be missing in production, unless
229
+ // we explicitly copy them. But even if we copy the all the files into
230
+ // the build output (which doesn't seem to be wise because it may contain
231
+ // private information such as files with API keys, for example), we would
232
+ // still have a problem. Since the filenames would be the same every time,
233
+ // browsers would cache their content, and updating file content would not
234
+ // work correctly. This is easily solved by importing assets through Webpack
235
+ // because if it can then append content hashes to filenames in production,
236
+ // just like it does for JS and CSS. And because we configured "html" loader
237
+ // to be used for HTML files, even <link href="./src/something.png"> would
238
+ // get resolved correctly by Webpack and handled both in development and
239
+ // in production without actually serving it by that path.
240
+ contentBase : [ ] ,
224
241
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
225
242
// for the WebpackDevServer client so it can learn when the files were
226
243
// updated. The WebpackDevServer client is included as an entry point
0 commit comments