使用gulp Uglify/minify Polymer web组件

dip*_*ent 1 minify uglifyjs polymer

我正在尝试使用gulp的uglify插件来缩小我的Web组件,但它失败了,因为它无法识别自定义的html标记.

是否有任何gulp插件可以缩小包含自定义标签的html?

小智 6

尝试gulp-htmlmin.

我在硫化之后用它来缩小我的elements.html文件,但我认为它也适用于非硫化元素.以下是我在gulpfile中调用插件的方法:

.pipe(htmlmin({
    removeEmptyAttributes: true,
    customAttrAssign: [{"source":"\\$="}],
    customAttrSurround: [
        [ {"source": "\\({\\{"}, {"source": "\\}\\}"} ],
        [ {"source": "\\[\\["}, {"source": "\\]\\]"}  ]
    ],
    collapseWhitespace: true,
    // always leave one space
    // because http://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace
    conservativeCollapse: true,
    minifyJS: true,
    minifyCSS: true,
    removeComments: true,
    removeCommentsFromCDATA: true,
    removeCDATASectionsFromCDATA: true
}))
Run Code Online (Sandbox Code Playgroud)