-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
26 lines (20 loc) · 960 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
const juice = require('juice');
let juiceOptions;
function HtmlWebpackInlinerPlugin(options) {
// Initialize
juiceOptions = options.juiceOptions || {};
}
HtmlWebpackInlinerPlugin.prototype.apply = compiler => {
(compiler.hooks
? compiler.hooks.compilation.tap.bind(compiler.hooks.compilation, 'html-webpack-inline-style-plugin')
: compiler.plugin.bind(compiler, 'compilation'))(compilation => {
(compilation.hooks
? compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tapAsync.bind(compilation.hooks.htmlWebpackPluginAfterHtmlProcessing, 'html-webpack-inline-style-plugin')
: compilation.plugin.bind(compilation, 'html-webpack-plugin-after-html-processing'))((htmlPluginData, callback) => {
htmlPluginData.html = juice(htmlPluginData.html, juiceOptions);
callback(null, htmlPluginData);
});
});
};
module.exports = HtmlWebpackInlinerPlugin;