Skip to content

Commit 209526e

Browse files
committed
Add option historyApiFallback
1 parent e350590 commit 209526e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/options.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
}
4949
]
5050
},
51+
"historyApiFallback": {
52+
"description": "When using the HTML5 History API, the index.html page will likely have to be served in place of any 404 responses. Enable historyApiFallback by setting it to true",
53+
"anyOf": [
54+
{
55+
"type": "boolean"
56+
}
57+
]
58+
},
5159
"stats": {
5260
"description": "Stats options object or preset name.",
5361
"anyOf": [

src/utils/getFilenameFromUrl.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ export default function getFilenameFromUrl(context, url) {
5353
filename = path.join(outputPath, querystring.unescape(pathname));
5454
}
5555

56-
let fsStats;
56+
if (!context.outputFileSystem.existsSync(filename) && options.historyApiFallback){
57+
filename = path.join(outputPath);
58+
}
5759

60+
let fsStats;
5861
try {
5962
fsStats = context.outputFileSystem.statSync(filename);
6063
} catch (_ignoreError) {

0 commit comments

Comments
 (0)