File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ const EntryPlugin = webpack.EntryPlugin;
1010class DevServerPlugin {
1111 /**
1212 * @param {?Object } options - Dev-Server options
13+ * @param {?Object } logger - Dev-Server logger
1314 */
14- constructor ( options ) {
15+ constructor ( options , logger ) {
1516 this . options = options ;
17+ this . logger = logger ;
1618 }
1719
1820 /**
@@ -163,6 +165,13 @@ class DevServerPlugin {
163165 additionalEntries . push ( hotEntry ) ;
164166 }
165167
168+ if ( ! isWebTarget ) {
169+ this . logger . info ( `A non-web target was selected in dev server config.` ) ;
170+ if ( this . options . liveReload ) {
171+ this . logger . warn ( `Live reload will not work with a non-web target.` ) ;
172+ }
173+ }
174+
166175 // use a hook to add entries if available
167176 if ( EntryPlugin ) {
168177 for ( const additionalEntry of additionalEntries ) {
Original file line number Diff line number Diff line change @@ -4,10 +4,11 @@ const DevServerPlugin = require('./DevServerPlugin');
44
55function updateCompiler ( compiler , options ) {
66 const compilers = compiler . compilers || [ compiler ] ;
7+ const logger = compiler . getInfrastructureLogger ( 'webpack-dev-server' ) ;
78
89 // eslint-disable-next-line no-shadow
910 compilers . forEach ( ( compiler ) => {
10- new DevServerPlugin ( options ) . apply ( compiler ) ;
11+ new DevServerPlugin ( options , logger ) . apply ( compiler ) ;
1112 } ) ;
1213}
1314
Original file line number Diff line number Diff line change @@ -95,6 +95,22 @@ describe('DevServer', () => {
9595 . catch ( done ) ;
9696 } ) ;
9797
98+ it ( 'should show a warning for live reloading with non-web target' , ( done ) => {
99+ testBin (
100+ '--config ./test/fixtures/dev-server/default-config.js --target node --live-reload'
101+ )
102+ . then ( ( output ) => {
103+ expect ( output . stderr ) . toContain (
104+ 'A non-web target was selected in dev server config'
105+ ) ;
106+ expect ( output . stderr ) . toContain (
107+ 'Live reload will not work with a non-web target'
108+ ) ;
109+ done ( ) ;
110+ } )
111+ . catch ( done ) ;
112+ } ) ;
113+
98114 it ( 'does not use client.path when default' , ( done ) => {
99115 testBin ( '--config ./test/fixtures/dev-server/client-default-path-config.js' )
100116 . then ( ( output ) => {
You can’t perform that action at this time.
0 commit comments