Skip to content

Commit 70fe50c

Browse files
committed
Merge branch 'historyapifallback-struggles'
2 parents b1abc23 + fb440b2 commit 70fe50c

File tree

6 files changed

+40
-3
lines changed

6 files changed

+40
-3
lines changed

lib/Server.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ function Server(compiler, options) {
228228
if(options.historyApiFallback) {
229229
// Fall back to /index.html if nothing else matches.
230230
app.use(
231-
historyApiFallback(typeof options.historyApiFallback === "object" ? options.historyApiFallback : null),
232-
contentBase ? express.static(contentBase) : undefined
231+
historyApiFallback(typeof options.historyApiFallback === "object" ? options.historyApiFallback : null)
233232
);
234233
}
235234
},
@@ -310,7 +309,7 @@ function Server(compiler, options) {
310309
if(options.watchContentBase)
311310
defaultFeatures.push("watchContentBase");
312311
if(options.historyApiFallback)
313-
defaultFeatures.push("historyApiFallback", "middleware");
312+
defaultFeatures.push("historyApiFallback", "middleware", "contentBaseFiles");
314313
defaultFeatures.push("magicHtml");
315314
if(contentBase !== false)
316315
defaultFeatures.push("contentBaseIndex");

test/HistoryApiFallback.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var request = require("supertest");
33
var helper = require("./helper");
44
var config = require("./fixtures/historyapifallback-config/webpack.config");
55
var config2 = require("./fixtures/historyapifallback-2-config/webpack.config");
6+
var config3 = require("./fixtures/historyapifallback-3-config/webpack.config");
67

78
describe("HistoryApiFallback", function() {
89
var server;
@@ -110,4 +111,20 @@ describe("HistoryApiFallback", function() {
110111
.expect(200, /Other file/, done);
111112
});
112113
});
114+
115+
describe("in-memory files", function() {
116+
before(function(done) {
117+
server = helper.start(config3, {
118+
contentBase: path.join(__dirname, "fixtures/historyapifallback-3-config"),
119+
historyApiFallback: true
120+
}, done);
121+
req = request(server.app);
122+
});
123+
124+
it("should take precedence over contentBase files", function(done) {
125+
req.get("/foo")
126+
.accept("html")
127+
.expect(200, /In-memory file/, done);
128+
});
129+
});
113130
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In-memory file
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require("./bar.html");
2+
console.log("Hey.");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
contentBase file
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
context: __dirname,
3+
entry: "./foo.js",
4+
output: {
5+
filename: "bundle.js",
6+
path: "/"
7+
},
8+
module: {
9+
loaders: [
10+
{
11+
test: /\.html$/,
12+
loader: "file",
13+
query: { name: "index.html" }
14+
}
15+
]
16+
}
17+
};

0 commit comments

Comments
 (0)