File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,9 @@ $ build-scripts start --help
3838Usage: build-scripts start [options]
3939
4040Options:
41- --port < port> 服务端口号
42- --host < host> 服务主机名
43- --config < config> 自定义配置文件路径(支持 json 或者 js,推荐命名 build.config.js/build.json)
41+ --port < port> 服务端口号
42+ --host < host> 服务主机名
43+ --config < config> 自定义配置文件路径(支持 json 或者 js,推荐命名 build.config.js/build.json)
4444```
4545
4646build 命令:
@@ -51,7 +51,7 @@ $ build-scripts build --help
5151Usage: build-scripts build [options]
5252
5353Options:
54- --config < config> 同 start
54+ --config < config> 同 start
5555```
5656
5757test 命令:
@@ -337,6 +337,21 @@ module.exports = ({ registerUserConfig }) => {
337337};
338338```
339339
340+ #### hasRegistration
341+
342+ 判断 build.json 中的顶层配置字段或者 cli 参数是否已经注册:
343+
344+ ``` js
345+ module .exports = ({ hasRegistration }) => {
346+ // 判断 build.json 顶层配置字段 entry 是否已配置
347+ const hasEntryRegistered = hasRegistration (' entry' );
348+
349+ // 判断 cli --https 参数是否已被注册
350+ const hasHttpsRegistered = hasRegistration (' https' , ' cliOption' );
351+ ...
352+ }
353+ ```
354+
340355#### modifyConfigRegistration
341356
342357用于修改已注册用户配置的行为:
Original file line number Diff line number Diff line change 88- [ feat] support deep merge of modifyUserConfig by options
99- [ feat] enhance registerMethod API, make it possible to get plugin name when applyMethod
1010- [ feat] add ` originalUserConfig ` to plugin API
11+ - [ feat] support ` hasRegistration ` api
1112- [ fix] move webpack-dev-server to peerDependencies and migrate webpack-dev-server to 4.0.0
1213
1314## 1.0.1
Original file line number Diff line number Diff line change @@ -717,6 +717,11 @@ class Context {
717717 this . registerConfig ( 'userConfig' , args ) ;
718718 } ;
719719
720+ public hasRegistration = ( name : string , type : 'cliOption' | 'userConfig' = 'userConfig' ) : boolean => {
721+ const mappedType = type === 'cliOption' ? 'cliOptionRegistration' : 'userConfigRegistration' ;
722+ return Object . keys ( this [ mappedType ] || { } ) . includes ( name ) ;
723+ } ;
724+
720725 public registerCliOption = ( args : MaybeArray < ICliOptionArgs > ) : void => {
721726 this . registerConfig ( 'cliOption' , args , name => {
722727 return camelCase ( name , { pascalCase : false } ) ;
@@ -766,6 +771,7 @@ class Context {
766771 setValue : this . setValue ,
767772 getValue : this . getValue ,
768773 registerUserConfig : this . registerUserConfig ,
774+ hasRegistration : this . hasRegistration ,
769775 registerCliOption : this . registerCliOption ,
770776 registerMethod : this . registerMethod ,
771777 applyMethod,
You can’t perform that action at this time.
0 commit comments