summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Wu2016-10-23 23:39:21 +0800
committerGitHub2016-10-23 23:39:21 +0800
commit4e13a44aaada3d3c35f0c58dfca55c3380c8e49f (patch)
tree0b3bdeb04af77da0b37f83406bb7f3def12251a4
parent0b9c17705882207894bc7733d26cbeb45a1ca861 (diff)
parent731375c220afee7b5907db97940092efe54f5063 (diff)
Merge pull request #231 from PeterDaveHello/html-minify
html minify in production environment
-rw-r--r--app.js13
-rw-r--r--package.json1
2 files changed, 14 insertions, 0 deletions
diff --git a/app.js b/app.js
index 0c66cc27..327d1f75 100644
--- a/app.js
+++ b/app.js
@@ -17,6 +17,7 @@ var morgan = require('morgan');
var passportSocketIo = require("passport.socketio");
var helmet = require('helmet');
var i18n = require('i18n');
+var minifyHTML = require('express-minify-html');
//core
var config = require("./lib/config.js");
@@ -56,6 +57,18 @@ app.use(morgan('combined', {
"stream": logger.stream
}));
+if (!config.debug) {
+ app.use(minifyHTML({
+ override: false,
+ htmlMinifier: {
+ removeComments: true,
+ collapseWhitespace: true,
+ collapseBooleanAttributes: true,
+ removeAttributeQuotes: true,
+ removeEmptyAttributes: true,
+ }));
+}
+
//socket io
var io = require('socket.io')(server);
diff --git a/package.json b/package.json
index 96b9c7e2..2e6377ff 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"ejs": "^2.5.2",
"engine.io-client": "^1.7.0",
"express": ">=4.14",
+ "express-minify-html": "^0.6.0",
"express-session": "^1.14.1",
"file-saver": "^1.3.3",
"flowchart.js": "^1.6.3",