繁体   English   中英

如何使用html-minifier npm模块?

[英]How to use html-minifier npm module?

我想使用此模块https://www.npmjs.com/package/html-minifier缩小来自node.js的html文件

我有这个代码

                // minify the html code
                fse.readFile(filename, function(err, data) {
                    if (err) return console.error(err);
                    var result = minify(data.toString(), {
                        removeAttributeQuotes: false
                    });
                    console.log(result);
                });

但是,它记录的代码与原始文件中的代码相同。 它没有缩小。 有人知道怎么了吗?

谢谢

默认情况下,几乎所有的html-minifier选项都是禁用的。

尝试一些选项

{
  collapseWhitespace: true,
  removeComments: true,
  removeEmptyAttributes: true,
  removeRedundantAttributes: true,
  removeScriptTypeAttributes: true,
  removeStyleLinkTypeAttributes: true
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM