File tree Expand file tree Collapse file tree 4 files changed +40
-14
lines changed Expand file tree Collapse file tree 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');
3333const setupExitSignals = require ( './utils/setupExitSignals' ) ;
3434const findPort = require ( './utils/findPort' ) ;
3535const schema = require ( './options.json' ) ;
36+ const isWebTarget = require ( './utils/isWebTarget' ) ;
3637
3738if ( ! process . env . WEBPACK_SERVE ) {
3839 process . env . WEBPACK_SERVE = true ;
@@ -662,6 +663,13 @@ class Server {
662663 ) ;
663664 }
664665
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+
665673 if ( this . options . open || this . options . openPage ) {
666674 runOpen ( localUrlForTerminal , this . options , this . logger ) ;
667675 }
Original file line number Diff line number Diff line change 33const webpack = require ( 'webpack' ) ;
44const createDomain = require ( './createDomain' ) ;
55const getSocketClientPath = require ( './getSocketClientPath' ) ;
6+ const isWebTarget = require ( './isWebTarget' ) ;
67
78// @ts -ignore
89const EntryPlugin = webpack . EntryPlugin ;
@@ -137,24 +138,11 @@ class DevServerPlugin {
137138
138139 compilerOptions . plugins = compilerOptions . plugins || [ ] ;
139140
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-
153141 /** @type {Entry } */
154142 const additionalEntries = checkInject (
155143 options . injectClient ,
156144 compilerOptions ,
157- isWebTarget
145+ isWebTarget ( compilerOptions )
158146 )
159147 ? [ clientEntry ]
160148 : [ ] ;
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', () => {
165165 } ) ;
166166 } ) ;
167167
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+
168182 it ( 'should log static' , ( done ) => {
169183 testBin (
170184 '--no-color' ,
You can’t perform that action at this time.
0 commit comments