Skip to content

Commit 95e930b

Browse files
committed
formatting
1 parent 4bfe3c2 commit 95e930b

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

index.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,33 @@ const cheerio = require('cheerio');
44
const uncss = require('uncss');
55

66
function HtmlWebpackUncssPlugin (options) {
7-
assert.equal(options, undefined, 'The HtmlWebpackUncssPlugin does not accept any options');
7+
assert.equal(options, undefined,
8+
'The HtmlWebpackUncssPlugin does not accept any options');
89
}
910

1011
HtmlWebpackUncssPlugin.prototype.apply = (compiler) => {
11-
compiler.plugin('compilation', function(compilation) {
12-
compilation.plugin('html-webpack-plugin-after-html-processing', function(htmlPluginData, callback) {
13-
const $ = cheerio.load(htmlPluginData.html);
14-
const styles = [];
15-
$('style').each(function() {
16-
const style = $(this).html();
17-
if (style) {
18-
styles.push(style);
19-
}
20-
});
12+
compiler.plugin('compilation', (compilation) => {
13+
compilation.plugin('html-webpack-plugin-after-html-processing',
14+
(data, callback) => {
15+
const $ = cheerio.load(data.html);
16+
const styles = [];
17+
$('style').each(function() {
18+
const style = $(this).html();
19+
if (style) {
20+
styles.push(style);
21+
}
22+
});
2123

22-
uncss($.html(), { raw: styles.join(' ') }, (error, output) => {
23-
if (error) {
24-
return callback(error);
25-
}
26-
$('style').slice(1).remove();
27-
$('style').text(output);
28-
htmlPluginData.html = $.html();
29-
return callback(null, htmlPluginData);
24+
uncss($.html(), { raw: styles.join(' ') }, (error, output) => {
25+
if (error) {
26+
return callback(error);
27+
}
28+
$('style').slice(1).remove();
29+
$('style').text(output);
30+
data.html = $.html();
31+
return callback(null, data);
32+
});
3033
});
31-
});
3234
});
3335
};
3436

0 commit comments

Comments
 (0)