File tree 4 files changed +40
-14
lines changed
4 files changed +40
-14
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ const getColorsOption = require('./utils/getColorsOption');
33
33
const setupExitSignals = require ( './utils/setupExitSignals' ) ;
34
34
const findPort = require ( './utils/findPort' ) ;
35
35
const schema = require ( './options.json' ) ;
36
+ const isWebTarget = require ( './utils/isWebTarget' ) ;
36
37
37
38
if ( ! process . env . WEBPACK_SERVE ) {
38
39
process . env . WEBPACK_SERVE = true ;
@@ -662,6 +663,13 @@ class Server {
662
663
) ;
663
664
}
664
665
666
+ if ( ! isWebTarget ( this . compiler . options ) ) {
667
+ this . logger . info ( `A non-web target was selected in dev server config.` ) ;
668
+ if ( this . options . liveReload ) {
669
+ this . logger . info ( `Live reload will not work with a non-web target.` ) ;
670
+ }
671
+ }
672
+
665
673
if ( this . options . open || this . options . openPage ) {
666
674
runOpen ( localUrlForTerminal , this . options , this . logger ) ;
667
675
}
Original file line number Diff line number Diff line change 3
3
const webpack = require ( 'webpack' ) ;
4
4
const createDomain = require ( './createDomain' ) ;
5
5
const getSocketClientPath = require ( './getSocketClientPath' ) ;
6
+ const isWebTarget = require ( './isWebTarget' ) ;
6
7
7
8
// @ts -ignore
8
9
const EntryPlugin = webpack . EntryPlugin ;
@@ -137,24 +138,11 @@ class DevServerPlugin {
137
138
138
139
compilerOptions . plugins = compilerOptions . plugins || [ ] ;
139
140
140
- /** @type {boolean } */
141
- const isWebTarget = compilerOptions . externalsPresets
142
- ? compilerOptions . externalsPresets . web
143
- : [
144
- 'web' ,
145
- 'webworker' ,
146
- 'electron-renderer' ,
147
- 'node-webkit' ,
148
- // eslint-disable-next-line no-undefined
149
- undefined ,
150
- null ,
151
- ] . includes ( compilerOptions . target ) ;
152
-
153
141
/** @type {Entry } */
154
142
const additionalEntries = checkInject (
155
143
options . injectClient ,
156
144
compilerOptions ,
157
- isWebTarget
145
+ isWebTarget ( compilerOptions )
158
146
)
159
147
? [ clientEntry ]
160
148
: [ ] ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const isWebTarget = ( compilerOptions ) =>
4
+ compilerOptions . externalsPresets
5
+ ? compilerOptions . externalsPresets . web
6
+ : [
7
+ 'web' ,
8
+ 'webworker' ,
9
+ 'electron-renderer' ,
10
+ 'node-webkit' ,
11
+ // eslint-disable-next-line no-undefined
12
+ undefined ,
13
+ null ,
14
+ ] . includes ( compilerOptions . target ) ;
15
+
16
+ module . exports = isWebTarget ;
Original file line number Diff line number Diff line change @@ -165,6 +165,20 @@ describe('CLI', () => {
165
165
} ) ;
166
166
} ) ;
167
167
168
+ it ( 'should show a warning for live reloading with non-web target' , ( done ) => {
169
+ testBin ( '--target node --live-reload' )
170
+ . then ( ( output ) => {
171
+ expect ( output . stderr ) . toContain (
172
+ 'A non-web target was selected in dev server config'
173
+ ) ;
174
+ expect ( output . stderr ) . toContain (
175
+ 'Live reload will not work with a non-web target'
176
+ ) ;
177
+ done ( ) ;
178
+ } )
179
+ . catch ( done ) ;
180
+ } ) ;
181
+
168
182
it ( 'should log static' , ( done ) => {
169
183
testBin (
170
184
'--no-color' ,
You can’t perform that action at this time.
0 commit comments