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 @@ -26,7 +26,7 @@ class WrapperPlugin {
2626 }
2727
2828 apply ( compiler ) {
29- const ConcatSource = compiler . webpack . sources . ConcatSource ;
29+ const ConcatSource = getSourceConcatenator ( compiler ) ;
3030
3131 const header = this . header ;
3232 const footer = this . footer ;
@@ -50,9 +50,9 @@ class WrapperPlugin {
5050 const footerContent = ( typeof footer === 'function' ) ? footer ( fileName , chunkHash ) : footer ;
5151
5252 compilation . assets [ fileName ] = new ConcatSource (
53- String ( headerContent ) ,
54- compilation . assets [ fileName ] ,
55- String ( footerContent ) ,
53+ String ( headerContent ) ,
54+ compilation . assets [ fileName ] ,
55+ String ( footerContent ) ,
5656 ) ;
5757 }
5858
@@ -73,3 +73,13 @@ class WrapperPlugin {
7373}
7474
7575module . exports = WrapperPlugin ;
76+
77+ function getSourceConcatenator ( compiler ) {
78+ const webpack = compiler . webpack ;
79+ if ( webpack ) {
80+ // webpack v5
81+ return webpack . sources . ConcatSource ;
82+ }
83+ // webpack v4
84+ return require ( "webpack-sources" ) . ConcatSource ;
85+ }
You can’t perform that action at this time.
0 commit comments