File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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[] }
@@ -3429,6 +3431,23 @@ class Server {
34293431 . then ( ( ) => callback ( ) , callback )
34303432 . catch ( callback ) ;
34313433 }
3434+
3435+ /**
3436+ * @param {Compiler } compiler compiler
3437+ * @returns {void }
3438+ */
3439+ apply ( compiler ) {
3440+ const pluginName = this . constructor . name ;
3441+ this . compiler = compiler ;
3442+
3443+ this . compiler . hooks . watchRun . tapPromise ( pluginName , async ( ) => {
3444+ await this . start ( ) ;
3445+ } ) ;
3446+
3447+ this . compiler . hooks . watchClose . tap ( pluginName , async ( ) => {
3448+ await this . stop ( ) ;
3449+ } ) ;
3450+ }
34323451}
34333452
34343453module . exports = Server ;
You can’t perform that action at this time.
0 commit comments