mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
[webpack-dev-server] Use HistoryApiFallbackOptions from connect-history-api-fallback (#35673)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
40e2b2c1a4
commit
a4e6a7babb
Vendored
+3
-19
@@ -6,6 +6,7 @@
|
||||
// Alan Agius <https://github.com/alan-agius4>
|
||||
// Artur Androsovych <https://github.com/arturovt>
|
||||
// Dave Cardwell <https://github.com/davecardwell>
|
||||
// Katsuya Hino <https://github.com/dobogo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -15,7 +16,7 @@ import * as express from 'express';
|
||||
import * as serveStatic from 'serve-static';
|
||||
import * as https from 'https';
|
||||
import * as http from 'http';
|
||||
import { Url } from "url";
|
||||
import * as connectHistoryApiFallback from 'connect-history-api-fallback';
|
||||
|
||||
declare namespace WebpackDevServer {
|
||||
interface ListeningApp {
|
||||
@@ -33,23 +34,6 @@ declare namespace WebpackDevServer {
|
||||
|
||||
type ProxyConfigArray = ProxyConfigArrayItem[];
|
||||
|
||||
interface Context {
|
||||
match: RegExpMatchArray;
|
||||
parsedUrl: Url;
|
||||
}
|
||||
|
||||
type RewriteTo = (context: Context) => string;
|
||||
|
||||
interface Rewrite {
|
||||
from: RegExp;
|
||||
to: string | RegExp | RewriteTo;
|
||||
}
|
||||
|
||||
interface HistoryApiFallbackConfig {
|
||||
disableDotRule?: boolean;
|
||||
rewrites?: Rewrite[];
|
||||
}
|
||||
|
||||
interface Configuration {
|
||||
/** Provides the ability to execute custom middleware after all other middleware internally within the server. */
|
||||
after?: (app: express.Application, server: WebpackDevServer) => void;
|
||||
@@ -87,7 +71,7 @@ declare namespace WebpackDevServer {
|
||||
[key: string]: string;
|
||||
};
|
||||
/** When using the HTML5 History API, the index.html page will likely have to be served in place of any 404 responses. */
|
||||
historyApiFallback?: boolean | HistoryApiFallbackConfig;
|
||||
historyApiFallback?: boolean | connectHistoryApiFallback.Options;
|
||||
/** Specify a host to use. By default this is localhost. */
|
||||
host?: string;
|
||||
/** Enable webpack's Hot Module Replacement feature. */
|
||||
|
||||
@@ -90,6 +90,25 @@ const c4: WebpackDevServer.Configuration = {
|
||||
const c5: WebpackDevServer.Configuration = {
|
||||
proxy: [{context: (pathname: string) => true}]
|
||||
};
|
||||
const c6: WebpackDevServer.Configuration = {
|
||||
historyApiFallback: {
|
||||
disableDotRule: true,
|
||||
htmlAcceptHeaders: ['text/html'],
|
||||
index: '/app/',
|
||||
logger: () => {},
|
||||
rewrites: [
|
||||
{
|
||||
from: /\/page/,
|
||||
to: '/page.html'
|
||||
},
|
||||
{
|
||||
from: /^\/images\/.*$/,
|
||||
to: (context) => '/assets/' + context.parsedUrl.pathname
|
||||
}
|
||||
],
|
||||
verbose: true
|
||||
}
|
||||
};
|
||||
|
||||
// API example
|
||||
server = new WebpackDevServer(compiler, config);
|
||||
|
||||
Reference in New Issue
Block a user