File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,8 @@ const DEFAULT_ALLOWED_PROTOCOLS = /^(file|.+-extension):/i;
311311 * @property {typeof useFn } use
312312 */
313313
314+ const pluginName = "webpack-dev-server" ;
315+
314316/**
315317 * @template {BasicApplication} [A=ExpressApplication]
316318 * @template {BasicServer} [S=HTTPServer]
@@ -330,7 +332,7 @@ class Server {
330332 /**
331333 * @type {ReturnType<Compiler["getInfrastructureLogger"]> }
332334 */
333- this . logger = this . compiler . getInfrastructureLogger ( "webpack-dev-server" ) ;
335+ this . logger = this . compiler . getInfrastructureLogger ( pluginName ) ;
334336 this . options = options ;
335337 /**
336338 * @type {FSWatcher[] }
@@ -3399,6 +3401,23 @@ class Server {
33993401 . then ( ( ) => callback ( ) , callback )
34003402 . catch ( callback ) ;
34013403 }
3404+
3405+ /**
3406+ * @param {Compiler } compiler compiler
3407+ * @returns {void }
3408+ */
3409+ apply ( compiler ) {
3410+ const pluginName = this . constructor . name ;
3411+ this . compiler = compiler ;
3412+
3413+ this . compiler . hooks . watchRun . tapPromise ( pluginName , async ( ) => {
3414+ await this . start ( ) ;
3415+ } ) ;
3416+
3417+ this . compiler . hooks . watchClose . tap ( pluginName , async ( ) => {
3418+ await this . stop ( ) ;
3419+ } ) ;
3420+ }
34023421}
34033422
34043423module . exports = Server ;
You can’t perform that action at this time.
0 commit comments