首页 > 解决方案 > Minifying the conditional statement used in the comments of HTML using gulp

问题描述

I want to minify the following HTML code. I am using the gulp-cleanhtml which works fine for me except the following mentioned criteria:

it does not minify the Styles of HTML conditional statements. Check the below code:

<!--[if gte mso 9]>
<style> 
sup 
   {   
     font-size:100% !important;
   }
</style>
<![endif]-->

Can anyone guide me how to go about? So that I can minify the code within those conditional statements?

标签: gulp

解决方案


gulp-htmlmin应该通过以下选项将您带到那里:

.pipe(
    htmlmin({
        collapseWhitespace: true,
        minifyCSS: true,
        processConditionalComments: true,
    })
)

这应该导致:

<!--[if gte mso 9]><style>sup{font-size:100%!important}</style><![endif]-->

推荐阅读