@@ -111,11 +111,11 @@ class HtmlWebpackPlugin {
111
111
} ) ;
112
112
113
113
compiler . hooks . emit . tapAsync ( 'HtmlWebpackPlugin' ,
114
- /**
115
- * Hook into the webpack emit phase
116
- * @param {WebpackCompilation } compilation
117
- * @param {() => void } callback
118
- */
114
+ /**
115
+ * Hook into the webpack emit phase
116
+ * @param {WebpackCompilation } compilation
117
+ * @param {() => void } callback
118
+ */
119
119
( compilation , callback ) => {
120
120
// Clear the childCompilerCache
121
121
childCompiler . clearCache ( compiler ) ;
@@ -156,7 +156,7 @@ class HtmlWebpackPlugin {
156
156
} ) ;
157
157
}
158
158
} )
159
- // Wait for the compilation to finish
159
+ // Wait for the compilation to finish
160
160
. then ( ( ) => compilationPromise )
161
161
. then ( compiledTemplate => {
162
162
// Allow to use a custom function / string instead
@@ -167,22 +167,22 @@ class HtmlWebpackPlugin {
167
167
// and replace it with its content
168
168
return self . evaluateCompilationResult ( compilation , compiledTemplate ) ;
169
169
} )
170
- // Allow plugins to make changes to the assets before invoking the template
171
- // This only makes sense to use if `inject` is `false`
172
- . then ( compilationResult => getHtmlWebpackPluginHooks ( compilation ) . htmlWebpackPluginBeforeHtmlGeneration . promise ( {
170
+ // Allow plugins to make changes to the assets before invoking the template
171
+ // This only makes sense to use if `inject` is `false`
172
+ . then ( compilationResult => getHtmlWebpackPluginHooks ( compilation ) . beforeHtmlGeneration . promise ( {
173
173
assets : assets ,
174
174
outputName : self . childCompilationOutputName ,
175
175
plugin : self
176
176
} )
177
177
. then ( ( ) => compilationResult ) )
178
- // Execute the template
178
+ // Execute the template
179
179
. then ( compilationResult => typeof compilationResult !== 'function'
180
180
? compilationResult
181
181
: self . executeTemplate ( compilationResult , assets , compilation ) )
182
- // Allow plugins to change the html before assets are injected
182
+ // Allow plugins to change the html before assets are injected
183
183
. then ( html => {
184
184
const pluginArgs = { html : html , assets : assets , plugin : self , outputName : self . childCompilationOutputName } ;
185
- return getHtmlWebpackPluginHooks ( compilation ) . htmlWebpackPluginBeforeHtmlProcessing . promise ( pluginArgs ) ;
185
+ return getHtmlWebpackPluginHooks ( compilation ) . beforeHtmlProcessing . promise ( pluginArgs ) ;
186
186
} )
187
187
. then ( result => {
188
188
const html = result . html ;
@@ -191,42 +191,42 @@ class HtmlWebpackPlugin {
191
191
const assetTags = self . generateHtmlTagObjects ( assets ) ;
192
192
const pluginArgs = { head : assetTags . head , body : assetTags . body , plugin : self , outputName : self . childCompilationOutputName } ;
193
193
// Allow plugins to change the assetTag definitions
194
- return getHtmlWebpackPluginHooks ( compilation ) . htmlWebpackPluginAlterAssetTags . promise ( pluginArgs )
194
+ return getHtmlWebpackPluginHooks ( compilation ) . alterAssetTags . promise ( pluginArgs )
195
195
. then ( result => self . postProcessHtml ( html , assets , { body : result . body , head : result . head } )
196
196
. then ( html => _ . extend ( result , { html : html , assets : assets } ) ) ) ;
197
197
} )
198
- // Allow plugins to change the html after assets are injected
198
+ // Allow plugins to change the html after assets are injected
199
199
. then ( result => {
200
200
const html = result . html ;
201
201
const assets = result . assets ;
202
202
const pluginArgs = { html : html , assets : assets , plugin : self , outputName : self . childCompilationOutputName } ;
203
- return getHtmlWebpackPluginHooks ( compilation ) . htmlWebpackPluginAfterHtmlProcessing . promise ( pluginArgs )
203
+ return getHtmlWebpackPluginHooks ( compilation ) . afterHtmlProcessing . promise ( pluginArgs )
204
204
. then ( result => result . html ) ;
205
205
} )
206
206
. catch ( err => {
207
- // In case anything went wrong the promise is resolved
208
- // with the error message and an error is logged
207
+ // In case anything went wrong the promise is resolved
208
+ // with the error message and an error is logged
209
209
compilation . errors . push ( prettyError ( err , compiler . context ) . toString ( ) ) ;
210
210
// Prevent caching
211
211
self . hash = null ;
212
212
return self . options . showErrors ? prettyError ( err , compiler . context ) . toHtml ( ) : 'ERROR' ;
213
213
} )
214
214
. then ( html => {
215
- // Replace the compilation result with the evaluated html code
215
+ // Replace the compilation result with the evaluated html code
216
216
compilation . assets [ self . childCompilationOutputName ] = {
217
217
source : ( ) => html ,
218
218
size : ( ) => html . length
219
219
} ;
220
220
} )
221
- . then ( ( ) => getHtmlWebpackPluginHooks ( compilation ) . htmlWebpackPluginAfterEmit . promise ( {
221
+ . then ( ( ) => getHtmlWebpackPluginHooks ( compilation ) . afterEmit . promise ( {
222
222
html : compilation . assets [ self . childCompilationOutputName ] ,
223
223
outputName : self . childCompilationOutputName ,
224
224
plugin : self
225
225
} ) . catch ( err => {
226
226
console . error ( err ) ;
227
227
return null ;
228
228
} ) . then ( ( ) => null ) )
229
- // Let webpack continue with it
229
+ // Let webpack continue with it
230
230
. then ( ( ) => {
231
231
callback ( ) ;
232
232
} ) ;
0 commit comments