You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
734 B
25 lines
734 B
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
|
|
class WebpackHtmlAppendPlugin {
|
|
constructor (content) {
|
|
this.content = content || ''
|
|
}
|
|
|
|
apply (compiler) {
|
|
compiler.hooks.compilation.tap('WebpackHtmlAppendPlugin', (compilation) => {
|
|
let beforeEmit = compilation.hooks.htmlWebpackPluginAfterHtmlProcessing
|
|
if (!beforeEmit && HtmlWebpackPlugin.getHooks) {
|
|
const hooks = HtmlWebpackPlugin.getHooks(compilation)
|
|
if (hooks) {
|
|
beforeEmit = hooks.beforeEmit
|
|
}
|
|
}
|
|
beforeEmit && beforeEmit.tapAsync('WebpackHtmlAppendPlugin', (data, cb) => {
|
|
data.html += this.content
|
|
cb(null, data)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = WebpackHtmlAppendPlugin
|
|
|