@@ -14,12 +14,12 @@ function createConfig(config, argv, { port }) {
14
14
options . bonjour = true ;
15
15
}
16
16
17
- if ( argv . host !== 'localhost' || ! options . host ) {
17
+ if ( argv . host && ( argv . host !== 'localhost' || ! options . host ) ) {
18
18
options . host = argv . host ;
19
19
}
20
20
21
- if ( argv [ 'allowed-hosts' ] ) {
22
- options . allowedHosts = argv [ 'allowed-hosts' ] . split ( ',' ) ;
21
+ if ( argv . allowedHosts ) {
22
+ options . allowedHosts = argv . allowedHosts . split ( ',' ) ;
23
23
}
24
24
25
25
if ( argv . public ) {
@@ -47,11 +47,11 @@ function createConfig(config, argv, { port }) {
47
47
}
48
48
}
49
49
50
- if ( ! options . filename ) {
50
+ if ( ! options . filename && firstWpOpt . output && firstWpOpt . output . filename ) {
51
51
options . filename = firstWpOpt . output && firstWpOpt . output . filename ;
52
52
}
53
53
54
- if ( ! options . watchOptions ) {
54
+ if ( ! options . watchOptions && firstWpOpt . watchOptions ) {
55
55
options . watchOptions = firstWpOpt . watchOptions ;
56
56
}
57
57
@@ -64,38 +64,42 @@ function createConfig(config, argv, { port }) {
64
64
process . stdin . resume ( ) ;
65
65
}
66
66
67
+ // TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
68
+ // We should prefer CLI arg under config, now we always prefer `hot` from `devServer`
67
69
if ( ! options . hot ) {
68
70
options . hot = argv . hot ;
69
71
}
70
72
73
+ // TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
74
+ // We should prefer CLI arg under config, now we always prefer `hotOnly` from `devServer`
71
75
if ( ! options . hotOnly ) {
72
- options . hotOnly = argv [ 'hot-only' ] ;
76
+ options . hotOnly = argv . hotOnly ;
73
77
}
74
78
75
- if ( ! options . clientLogLevel ) {
76
- options . clientLogLevel = argv [ 'client-log-level' ] ;
79
+ // TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
80
+ // We should prefer CLI arg under config, now we always prefer `clientLogLevel` from `devServer`
81
+ if ( ! options . clientLogLevel && argv . clientLogLevel ) {
82
+ options . clientLogLevel = argv . clientLogLevel ;
77
83
}
78
84
79
- // eslint-disable-next-line
80
- if ( options . contentBase === undefined ) {
81
- if ( argv [ 'content-base' ] ) {
82
- options . contentBase = argv [ 'content-base' ] ;
85
+ if ( argv . contentBase ) {
86
+ options . contentBase = argv . contentBase ;
83
87
84
- if ( Array . isArray ( options . contentBase ) ) {
85
- options . contentBase = options . contentBase . map ( ( p ) => path . resolve ( p ) ) ;
86
- } else if ( / ^ [ 0 - 9 ] $ / . test ( options . contentBase ) ) {
87
- options . contentBase = + options . contentBase ;
88
- } else if ( ! / ^ ( h t t p s ? : ) ? \/ \/ / . test ( options . contentBase ) ) {
89
- options . contentBase = path . resolve ( options . contentBase ) ;
90
- }
91
- // It is possible to disable the contentBase by using
92
- // `--no-content-base`, which results in arg["content-base"] = false
93
- } else if ( argv [ 'content-base' ] === false ) {
94
- options . contentBase = false ;
88
+ if ( Array . isArray ( options . contentBase ) ) {
89
+ options . contentBase = options . contentBase . map ( ( p ) => path . resolve ( p ) ) ;
90
+ } else if ( / ^ [ 0 - 9 ] $ / . test ( options . contentBase ) ) {
91
+ options . contentBase = + options . contentBase ;
92
+ } else if ( ! / ^ ( h t t p s ? : ) ? \/ \/ / . test ( options . contentBase ) ) {
93
+ options . contentBase = path . resolve ( options . contentBase ) ;
95
94
}
95
+ // It is possible to disable the contentBase by using
96
+ // `--no-content-base`, which results in arg["content-base"] = false
97
+ } else if ( argv . contentBase === false ) {
98
+ // TODO doesn't work need fix, `false` in this case is string
99
+ options . contentBase = false ;
96
100
}
97
101
98
- if ( argv [ 'watch-content-base' ] ) {
102
+ if ( argv . watchContentBase ) {
99
103
options . watchContentBase = true ;
100
104
}
101
105
@@ -108,7 +112,8 @@ function createConfig(config, argv, { port }) {
108
112
109
113
if (
110
114
typeof options . stats === 'object' &&
111
- typeof options . stats . colors === 'undefined'
115
+ typeof options . stats . colors === 'undefined' &&
116
+ argv . color
112
117
) {
113
118
options . stats = Object . assign ( { } , options . stats , { colors : argv . color } ) ;
114
119
}
@@ -117,10 +122,12 @@ function createConfig(config, argv, { port }) {
117
122
options . lazy = true ;
118
123
}
119
124
125
+ // TODO remove in `v4`
120
126
if ( ! argv . info ) {
121
127
options . noInfo = true ;
122
128
}
123
129
130
+ // TODO remove in `v4`
124
131
if ( argv . quiet ) {
125
132
options . quiet = true ;
126
133
}
@@ -129,29 +136,29 @@ function createConfig(config, argv, { port }) {
129
136
options . https = true ;
130
137
}
131
138
132
- if ( argv [ 'pfx-passphrase' ] ) {
133
- options . pfxPassphrase = argv [ 'pfx-passphrase' ] ;
139
+ if ( argv . pfxPassphrase ) {
140
+ options . pfxPassphrase = argv . pfxPassphrase ;
134
141
}
135
142
136
143
if ( argv . inline === false ) {
137
144
options . inline = false ;
138
145
}
139
146
140
- if ( argv [ 'history-api-fallback' ] ) {
147
+ if ( argv . historyApiFallback ) {
141
148
options . historyApiFallback = true ;
142
149
}
143
150
144
151
if ( argv . compress ) {
145
152
options . compress = true ;
146
153
}
147
154
148
- if ( argv [ 'disable-host-check' ] ) {
155
+ if ( argv . disableHostCheck ) {
149
156
options . disableHostCheck = true ;
150
157
}
151
158
152
- if ( argv [ 'open-page' ] ) {
159
+ if ( argv . openPage ) {
153
160
options . open = true ;
154
- options . openPage = argv [ 'open-page' ] ;
161
+ options . openPage = argv . openPage ;
155
162
}
156
163
157
164
if ( typeof argv . open !== 'undefined' ) {
0 commit comments