@@ -8,6 +8,7 @@ let webpackVersion = 4
88
99const styleExtensions = [ '.css' , '.scss' , '.styl' , '.sass' , '.less' ]
1010const pluginName = 'PurgeCSS'
11+ const purgedStats = { }
1112
1213export default class PurgecssPlugin {
1314 constructor ( options ) {
@@ -23,10 +24,23 @@ export default class PurgecssPlugin {
2324 compiler . hooks . compilation . tap ( pluginName , compilation => {
2425 this . initializePlugin ( compilation )
2526 } )
27+ compiler . hooks . done . tapAsync ( pluginName , ( stats , cb ) => {
28+ this . addStats ( stats ) ;
29+ cb ( ) ;
30+ } )
2631 } else {
2732 compiler . plugin ( 'this-compilation' , compilation => {
2833 this . initializePlugin ( compilation )
2934 } )
35+ compiler . plugin ( 'done' , stats => {
36+ this . addStats ( stats )
37+ } )
38+ }
39+ }
40+
41+ addStats ( stats ) {
42+ if ( this . options . rejected ) {
43+ stats . purged = purgedStats
3044 }
3145 }
3246
@@ -100,8 +114,15 @@ export default class PurgecssPlugin {
100114 if ( typeof options . whitelistPatternsChildren === 'function' ) {
101115 options . whitelistPatternsChildren = options . whitelistPatternsChildren ( )
102116 }
117+
103118 const purgecss = new Purgecss ( options )
104- compilation . assets [ name ] = new ConcatSource ( purgecss . purge ( ) [ 0 ] . css )
119+ const purged = purgecss . purge ( ) [ 0 ] ;
120+
121+ if ( purged . rejected ) {
122+ purgedStats [ name ] = purged . rejected ;
123+ }
124+
125+ compilation . assets [ name ] = new ConcatSource ( purged . css )
105126 } )
106127 } )
107128
0 commit comments