Skip to content

Commit

Permalink
feat(koa): implement htmlMinifier
Browse files Browse the repository at this point in the history
  • Loading branch information
kiki-le-singe committed Jan 9, 2017
1 parent 448fabd commit fe9f890
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/server/koa.prod.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Koa from 'koa'
import compress from 'koa-compress'
import staticCache from 'koa-static-cache'
import htmlMinifier from 'koa-html-minifier'
import _debug from 'debug'
import serve from 'koa-static'
import convert from 'koa-convert'
Expand All @@ -17,6 +18,27 @@ app.use(compress({
flush: require('zlib').Z_SYNC_FLUSH
}))

app.use(convert(htmlMinifier({
caseSensitive: true,
removeComments: true,
removeCommentsFromCDATA: true,
removeCDATASectionsFromCDATA: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
collapseInlineTagWhitespace: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
decodeEntities: true,
})))

app.use(convert(staticCache(paths('staticDir'), {
maxAge: 365 * 24 * 60 * 60 // Add these files to caches for a year
})))
Expand Down

0 comments on commit fe9f890

Please sign in to comment.