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