Skip to content

Commit f48e442

Browse files
docs: improve (#1528)
1 parent 503d290 commit f48e442

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,34 @@ instance.waitUntilValid(() => {
388388
});
389389
```
390390

391-
## Known Issues
391+
## FAQ
392392

393-
### Multiple Successive Builds
393+
### Avoid blocking requests to non-webpack resources.
394394

395-
Watching will frequently cause multiple compilations
396-
as the bundle changes during compilation. This is due in part to cross-platform
397-
differences in file watchers, so that webpack doesn't loose file changes when
398-
watched files change rapidly. If you run into this situation, please make use of
399-
the [`TimeFixPlugin`](https://github.com/egoist/time-fix-plugin).
395+
Since `output.publicPath` and `output.filename`/`output.chunkFilename` can be dynamic, it's not possible to know which files are webpack bundles (and they public paths) and which are not, so we can't avoid blocking requests.
396+
397+
But there is a solution to avoid it - mount the middleware to a non-root route, for example:
398+
399+
```js
400+
const webpack = require("webpack");
401+
const middleware = require("webpack-dev-middleware");
402+
const compiler = webpack({
403+
// webpack options
404+
});
405+
const express = require("express");
406+
const app = express();
407+
408+
// Mounting the middleware to the non-root route allows avoids this.
409+
// Note - check your public path, if you want to handle `/dist/`, you need to setup `output.publicPath` to `/` value.
410+
app.use(
411+
"/dist/",
412+
middleware(compiler, {
413+
// webpack-dev-middleware options
414+
})
415+
);
416+
417+
app.listen(3000, () => console.log("Example app listening on port 3000!"));
418+
```
400419

401420
## Server-Side Rendering
402421

0 commit comments

Comments
 (0)