代码拉取完成,页面将自动刷新
var inline = require('inline-source')
function HtmlWebpackInlinePlugin(options) {
// Setup the plugin instance with options...
this.options = options
}
HtmlWebpackInlinePlugin.prototype.apply = function(compiler) {
let self = this
if (compiler.hooks) {
compiler.hooks.compilation.tap('HtmlWebpackInlinePlugin', compilation => {
if (!compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing) {
throw new Error('The expected HtmlWebpackPlugin hook was not found! Ensure HtmlWebpackPlugin is installed and was initialized before this plugin.');
}
compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing.tapAsync(
'HtmlWebpackInlinePlugin',
(htmlPluginData, callback) => {
var html = htmlPluginData.html
inline(html, self.options, function(err, html) {
if (err) {
return callback(err)
}
htmlPluginData.html = html
callback(null, htmlPluginData)
})
}
)
})
} else {
compiler.plugin('compilation', (compilation, options) => {
compilation.plugin('html-webpack-plugin-before-html-processing', (htmlPluginData, callback) => {
var html = htmlPluginData.html
inline(html, self.options, function(err, html) {
if (err) {
return callback(err)
}
htmlPluginData.html = html
callback(null, htmlPluginData)
})
})
})
}
};
module.exports = HtmlWebpackInlinePlugin
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。