2017-05-13 55 views
0

我想使用此模块https://www.npmjs.com/package/html-minifier如何使用html-minifier npm模块?

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); 
       }); 

但是它记录相同的代码从原来的文件。它没有缩小它。有谁知道什么是错的?

谢谢

回答

2

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

尝试用一些options

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