Skip to content

Commit

Permalink
feat(kkt): Enhanced devServer api.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jan 22, 2021
1 parent 71d5902 commit 8c22ff7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ import { LoaderConfOptions, MockerAPIOptions } from 'kkt';

type KKTRC = {
proxySetup?: (app: express.Application) => MockerAPIOptions;
devServer?: (config: WebpackDevServer.Configuration) => WebpackDevServer.Configuration;
devServer?: (config: WebpackDevServer.Configuration, options: DevServerOptions) => WebpackDevServer.Configuration;
default?: (conf: Configuration, evn: string, options: LoaderConfOptions) => Configuration | Promise<Configuration>;
};
```
Expand Down
2 changes: 1 addition & 1 deletion core/src/scripts/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default async function build(argvs: ParsedArgs) {
const serverConf = createDevServerConfig(proxy, allowedHost);
serverConf.headers = { ...serverConf.headers, 'Access-Control-Allow-Origin': '*' };
if (kktrc && kktrc.devServer && typeof kktrc.devServer === 'function') {
return kktrc.devServer(serverConf);
return kktrc.devServer(serverConf, { ...argvs, paths });
}
return serverConf;
};
Expand Down
4 changes: 3 additions & 1 deletion core/src/utils/loaderConf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ export type DevServerConfigFunction = (
allowedHost: string,
) => WebpackDevServer.Configuration;

export type DevServerOptions = ParsedArgs & Pick<LoaderConfOptions, 'paths' | 'paths'>;

export type KKTRC = {
proxySetup?: (app: express.Application) => MockerAPIOptions;
devServer?: (config: WebpackDevServer.Configuration) => WebpackDevServer.Configuration;
devServer?: (config: WebpackDevServer.Configuration, options: DevServerOptions) => WebpackDevServer.Configuration;
default?: (conf: Configuration, evn: string, options: LoaderConfOptions) => Configuration | Promise<Configuration>;
};

Expand Down

0 comments on commit 8c22ff7

Please sign in to comment.