File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -133,14 +133,21 @@ class MiniCssExtractPlugin {
133
133
compilation . hooks . normalModuleLoader . tap ( pluginName , ( lc , m ) => {
134
134
const loaderContext = lc ;
135
135
const module = m ;
136
- loaderContext [ NS ] = ( content ) => {
136
+ loaderContext [ NS ] = ( content , assets ) => {
137
137
if ( ! Array . isArray ( content ) && content != null ) {
138
138
throw new Error (
139
139
`Exported value was not extracted as an array: ${ JSON . stringify (
140
140
content
141
141
) } `
142
142
) ;
143
143
}
144
+
145
+ module . buildInfo = module . buildInfo || { assets : { } } ;
146
+ module . buildInfo . assets = {
147
+ ...module . buildInfo . assets ,
148
+ ...assets ,
149
+ } ;
150
+
144
151
const identifierCountMap = new Map ( ) ;
145
152
for ( const line of content ) {
146
153
const count = identifierCountMap . get ( line . identifier ) || 0 ;
Original file line number Diff line number Diff line change @@ -78,11 +78,19 @@ export function pitch(request) {
78
78
) ;
79
79
80
80
let source ;
81
+ let assets = { } ;
81
82
childCompiler . hooks . afterCompile . tap ( pluginName , ( compilation ) => {
82
83
source =
83
84
compilation . assets [ childFilename ] &&
84
85
compilation . assets [ childFilename ] . source ( ) ;
85
86
87
+ // Collect assets from modules
88
+ compilation . modules . forEach ( ( module ) => {
89
+ if ( module . buildInfo && module . buildInfo . assets ) {
90
+ assets = { ...assets , ...module . buildInfo . assets } ;
91
+ }
92
+ } ) ;
93
+
86
94
// Remove all chunk assets
87
95
compilation . chunks . forEach ( ( chunk ) => {
88
96
chunk . files . forEach ( ( file ) => {
@@ -125,7 +133,7 @@ export function pitch(request) {
125
133
} ;
126
134
} ) ;
127
135
}
128
- this [ NS ] ( text ) ;
136
+ this [ NS ] ( text , assets ) ;
129
137
} catch ( e ) {
130
138
return callback ( e ) ;
131
139
}
You can’t perform that action at this time.
0 commit comments