minify error handling
This commit is contained in:
parent
eefe5742c4
commit
85e28d66c1
|
@ -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 ) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user