UNPKG

517 BJavaScriptView Raw
1const posthtml = require('posthtml');
2const htmlnano = require('htmlnano');
3
4module.exports = async function(asset) {
5 await asset.parseIfNeeded();
6
7 let htmlNanoConfig = Object.assign(
8 {},
9 await asset.getConfig(['.htmlnanorc', '.htmlnanorc.js'], {
10 packageKey: 'htmlnano'
11 }),
12 {
13 minifyCss: false,
14 minifyJs: false
15 }
16 );
17
18 let res = await posthtml([htmlnano(htmlNanoConfig)]).process(asset.ast, {
19 skipParse: true
20 });
21
22 asset.ast = res.tree;
23 asset.isAstDirty = true;
24};