Skip to content

Commit df0754e

Browse files
authored
feat: #169 ko.config.js support devServer client (#170)
* feat: #169 ko.config.js support devServer client * docs(changeset): ko.config.js support devServer client
1 parent c189db4 commit df0754e

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

.changeset/spicy-fireants-tell.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ko': patch
3+
---
4+
5+
ko.config.js support devServer client

packages/ko/src/actions/dev.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,33 @@ class Dev extends ActionFactory {
1717

1818
private get devServerConfig(): DevServerConfiguration {
1919
const { serve, publicPath } = this.service.config;
20-
const { host, port, proxy, staticPath, historyApiFallback = false } = serve;
20+
const {
21+
host,
22+
port,
23+
proxy,
24+
client = {
25+
overlay: {
26+
errors: true,
27+
warnings: false,
28+
runtimeErrors: true,
29+
},
30+
},
31+
staticPath,
32+
historyApiFallback = false,
33+
} = serve;
2134
return {
2235
port,
2336
host,
2437
hot: true,
2538
proxy,
39+
client,
2640
static: {
2741
directory: staticPath,
2842
watch: true,
2943
publicPath,
3044
},
3145
setupExitSignals: false,
3246
allowedHosts: 'all',
33-
client: {
34-
overlay: {
35-
errors: true,
36-
warnings: false,
37-
runtimeErrors: true,
38-
},
39-
},
4047
historyApiFallback,
4148
};
4249
}

packages/ko/src/types.ts

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Pattern } from 'copy-webpack-plugin';
22
import { Plugin } from 'postcss';
33
import { IKeys, IOpts } from 'ko-lints';
44
import { IOpts as AutoPolyfillsWebpackPluginOptions } from '@dtinsight/auto-polyfills-webpack-plugin';
5+
import { ClientConfiguration } from 'webpack-dev-server';
56

67
export type IOptions = {
78
//common configs
@@ -86,13 +87,15 @@ export type IOptions = {
8687
// dev, or serve configs
8788
/**
8889
* Options for the development server.
90+
* Docs url: https://webpack.js.org/configuration/dev-server/
8991
* @param {{proxy?: Record<string, any>, host: string, port: number, staticPath?: string, historyApiFallback?: any, compilationSuccessInfo?: { messages: string[]; notes?: string[] }}}
9092
*/
9193
serve: {
9294
proxy?: Record<string, any>;
9395
host: string;
9496
port: number;
9597
staticPath?: string;
98+
client?: boolean | ClientConfiguration | undefined;
9699
historyApiFallback?: any;
97100
compilationSuccessInfo?: { messages: string[]; notes?: string[] };
98101
};

website/docs/configuration.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ title: Configuration
66
You can custom ko's action via **ko.config.js**, below are supported configurations:
77

88
``` typescript
9+
import { ClientConfiguration } from 'webpack-dev-server';
10+
911
export type IOptions = {
1012
//common configs
1113
cwd: string; //current working directory
@@ -32,6 +34,7 @@ export type IOptions = {
3234
host: string; // host of dev server
3335
port: number; // port of dev server
3436
staticPath?: string; // static path that will be watch of dev server
37+
client?: boolean | ClientConfiguration | undefined; // client of dev server
3538
compilationSuccessInfo?: { messages: string[]; notes?: string[] }; // log after successful compilation, as same as friendly-errors-webpack-plugin
3639
};
3740
// experimental features

website/i18n/zh-CN/docusaurus-plugin-content-docs/current/configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export type IOptions = {
3232
host: string; // 开发服务器的主机名
3333
port: number; // 开发服务器的端口
3434
staticPath?: string; // 监视的资源路径
35+
client?: boolean | ClientConfiguration | undefined; // 日志、错误捕获等配置项
3536
compilationSuccessInfo?: { messages: string[]; notes?: string[] }; // 成功编译后的日志,与 friendly-errors-webpack-plugin 相同
3637
};
3738
// 实验性功能

0 commit comments

Comments
 (0)