I need my sails.js app to serve minified html to the user. So it is hard to read by the user. Has anyone done this before ?
Thank you.
This works for me: https://github.com/balderdashy/sails/issues/2188#issuecomment-56994236
In config/views.js:
var minify = require('html-minifier').minify;
var ejs = require('ejs-locals');
var parsing = function(path,options,fn) {
options.locals = options.locals || {};
options.locals._layoutFile = 'layout.ejs';
ejs(path, options, function(err, str){
str = minify(str,{collapseWhitespace: true, removeComments: true});
return fn(err, str);
});
};
module.exports.views = {
engine: {
ext: 'ejs',
fn: parsing
},
layout: false
};