Skip to content

Commit dbc4417

Browse files
committed
don't block request that are hashed and available
1 parent 5092585 commit dbc4417

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

middleware.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
var MemoryFileSystem = require("memory-fs");
66
var mime = require("mime");
77

8+
var HASH_REGEXP = /[0-9a-f]{10,}/;
9+
810
// constructor for the middleware
911
module.exports = function(compiler, options) {
1012
if(!options) options = {};
@@ -148,8 +150,17 @@ module.exports = function(compiler, options) {
148150
if(options.lazy && (!options.filename || options.filename.test(filename)))
149151
rebuild();
150152

153+
if(HASH_REGEXP.test(filename)) {
154+
try {
155+
if(fs.statSync(filename).isFile()) {
156+
processRequest();
157+
return;
158+
}
159+
} catch(e) {}
160+
}
151161
// delay the request until we have a vaild bundle
152-
ready(function() {
162+
ready(processRequest, req);
163+
function processRequest() {
153164
try {
154165
var stat = fs.statSync(filename);
155166
if(!stat.isFile()) {
@@ -176,7 +187,7 @@ module.exports = function(compiler, options) {
176187
}
177188
}
178189
res.send(content);
179-
}, req);
190+
}
180191
}
181192

182193
webpackDevMiddleware.getFilenameFromUrl = getFilenameFromUrl;

0 commit comments

Comments
 (0)