File tree 3 files changed +28
-2
lines changed
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;
10
10
class DevServerPlugin {
11
11
/**
12
12
* @param {?Object } options - Dev-Server options
13
+ * @param {?Object } logger - Dev-Server logger
13
14
*/
14
- constructor ( options ) {
15
+ constructor ( options , logger ) {
15
16
this . options = options ;
17
+ this . logger = logger ;
16
18
}
17
19
18
20
/**
@@ -163,6 +165,13 @@ class DevServerPlugin {
163
165
additionalEntries . push ( hotEntry ) ;
164
166
}
165
167
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
+
166
175
// use a hook to add entries if available
167
176
if ( EntryPlugin ) {
168
177
for ( const additionalEntry of additionalEntries ) {
Original file line number Diff line number Diff line change @@ -4,10 +4,11 @@ const DevServerPlugin = require('./DevServerPlugin');
4
4
5
5
function updateCompiler ( compiler , options ) {
6
6
const compilers = compiler . compilers || [ compiler ] ;
7
+ const logger = compiler . getInfrastructureLogger ( 'webpack-dev-server' ) ;
7
8
8
9
// eslint-disable-next-line no-shadow
9
10
compilers . forEach ( ( compiler ) => {
10
- new DevServerPlugin ( options ) . apply ( compiler ) ;
11
+ new DevServerPlugin ( options , logger ) . apply ( compiler ) ;
11
12
} ) ;
12
13
}
13
14
Original file line number Diff line number Diff line change @@ -95,6 +95,22 @@ describe('DevServer', () => {
95
95
. catch ( done ) ;
96
96
} ) ;
97
97
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
+
98
114
it ( 'does not use client.path when default' , ( done ) => {
99
115
testBin ( '--config ./test/fixtures/dev-server/client-default-path-config.js' )
100
116
. then ( ( output ) => {
You can’t perform that action at this time.
0 commit comments