Uglify/minify 使用 gulp 的聚合物网络组件

Uglify/minify Polymer web components using gulp

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

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

要做到这一点是相当具有挑战性的。您使用 crisper plugin to factor out the script into it's own file. You can then minify the script source. Afterwards use vulcanize 将脚本内联回 HTML.

尝试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
}))