2016-02-04 56 views

回答

0

要做到這一點非常困難。您使用crisper插件將腳本分解爲它自己的文件。然後您可以縮小腳本源。之後使用vulcanize將您的腳本內聯到HTML中。

5

試用gulp-htmlmin

硫化後我用它來縮小我的elements.html文件,但我想它應該也適用於非硫化元素。 以下是我在我的gulp文件中調用插件的方法:

.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 
})) 
+0

這是一個很好的答案!謝謝 –