Javascript 如何使用html minifier npm模块?
我想使用此模块缩小node.js中的html文件 我有这个密码Javascript 如何使用html minifier npm模块?,javascript,html,node.js,Javascript,Html,Node.js,我想使用此模块缩小node.js中的html文件 我有这个密码 // minify the html code fse.readFile(filename, function(err, data) { if (err) return console.error(err); var result = minify(data.toString(), {
// 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缩略器选项都被禁用 尝试一些:
{
collapseWhitespace: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}