File tree Expand file tree Collapse file tree 2 files changed +49
-3
lines changed
Expand file tree Collapse file tree 2 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,19 @@ function koaDevware(dev, compiler) {
2121 resolve ( true ) ;
2222 } ) ;
2323
24- compiler . hooks . failed . tap ( 'KoaWebpack' , ( error ) => {
25- reject ( error ) ;
26- } ) ;
24+ function tapFailedHook ( comp ) {
25+ comp . hooks . failed . tap ( 'KoaWebpack' , ( error ) => {
26+ reject ( error ) ;
27+ } ) ;
28+ }
29+
30+ if ( compiler . compilers ) {
31+ for ( const child of compiler . compilers ) {
32+ tapFailedHook ( child ) ;
33+ }
34+ } else {
35+ tapFailedHook ( compiler ) ;
36+ }
2737 } ) ;
2838 }
2939
Original file line number Diff line number Diff line change @@ -90,6 +90,42 @@ describe('koa-webpack', () => {
9090 } ) ;
9191 } ) . timeout ( 5e3 ) ;
9292
93+ it ( 'sends the result to a MultiCompiler in watch mode' , ( done ) => {
94+ const { middleware, req, server } = setup ( {
95+ dev : { lazy : false } ,
96+ config : [
97+ {
98+ entry : [ path . resolve ( __dirname , 'fixtures' , 'input.js' ) ] ,
99+ output : {
100+ path : path . resolve ( __dirname , 'fixtures' ) ,
101+ filename : 'output.js'
102+ }
103+ } ,
104+ {
105+ entry : [ path . resolve ( __dirname , 'fixtures' , 'input.js' ) ] ,
106+ output : {
107+ path : path . resolve ( __dirname , 'fixtures' ) ,
108+ filename : 'output2.js'
109+ }
110+ }
111+ ]
112+ } ) ;
113+ req . get ( '/output.js' )
114+ . expect ( 200 )
115+ . expect ( ( response ) => {
116+ assert . ok ( / H e l l o w o r l d / . test ( response . text ) , "Expected result to contain 'Hello world'" ) ;
117+ } )
118+ . then ( ( ) => req . get ( '/output2.js' )
119+ . expect ( 200 )
120+ . expect ( ( response ) => {
121+ assert . ok ( / H e l l o w o r l d / . test ( response . text ) , "Expected result to contain 'Hello world'" ) ;
122+ } )
123+ . then ( ( ) => {
124+ server . kill ( ) ;
125+ middleware . close ( done ) ;
126+ } ) ) ;
127+ } ) . timeout ( 5e3 ) ;
128+
93129 it ( 'builds and sends the result in lazy mode' , ( done ) => {
94130 const { middleware, req, server } = setup ( { dev : { lazy : true } } ) ;
95131 req . get ( '/output.js' )
You can’t perform that action at this time.
0 commit comments