File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
5555 context = options . context ;
5656 }
5757
58- compiler . plugin ( ' emit' , ( compilation , cb ) => {
58+ const emit = ( compilation , cb ) => {
5959 debug ( 'starting emit' ) ;
6060 const callback = ( ) => {
6161 debug ( 'finishing emit' ) ;
@@ -103,9 +103,9 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
103103 compilation . errors . push ( err ) ;
104104 } )
105105 . then ( ( ) => callback ( ) ) ;
106- } ) ;
106+ } ;
107107
108- compiler . plugin ( 'after-emit' , ( compilation , cb ) => {
108+ const afterEmit = ( compilation , cb ) => {
109109 debug ( 'starting after-emit' ) ;
110110 const callback = ( ) => {
111111 debug ( 'finishing after-emit' ) ;
@@ -153,7 +153,17 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
153153 }
154154
155155 callback ( ) ;
156- } ) ;
156+ } ;
157+
158+ if ( compiler . hooks ) {
159+ const plugin = { name : 'CopyPlugin' } ;
160+
161+ compiler . hooks . emit . tapAsync ( plugin , emit ) ;
162+ compiler . hooks . afterEmit . tapAsync ( plugin , afterEmit ) ;
163+ } else {
164+ compiler . plugin ( 'emit' , emit ) ;
165+ compiler . plugin ( 'after-emit' , afterEmit ) ;
166+ }
157167 } ;
158168
159169 return {
You can’t perform that action at this time.
0 commit comments