minify error handling

This commit is contained in:
vss-devel 2019-03-03 17:31:24 +03:00
parent eefe5742c4
commit 85e28d66c1

View File

@ -563,6 +563,7 @@ class Article extends ArticleStub {
async preProcess( data ) { async preProcess( data ) {
let src let src
let out
try { try {
src = cheerio.load( data ) src = cheerio.load( data )
} catch ( e ) { } catch ( e ) {
@ -619,20 +620,25 @@ class Article extends ArticleStub {
this.mimeType = 'text/html' this.mimeType = 'text/html'
this.encoding = 'utf-8' this.encoding = 'utf-8'
const out = dom.html() out = dom.html()
const minified = minify( out, { } catch ( err ) {
log( err )
return data
}
try {
out = minify( out, {
collapseWhitespace: true, collapseWhitespace: true,
conservativeCollapse: true, conservativeCollapse: true,
decodeEntities: true, decodeEntities: true,
sortAttributes: true, sortAttributes: true,
sortClassName: true, sortClassName: true,
removeComments: true, removeComments: true,
html5: false,
}) })
return minified
} catch ( err ) { } catch ( err ) {
log( err ) log( 'minify', err )
return null
} }
return out
} }
transformLink( elem ) { transformLink( elem ) {