amp-toolbox
amp-toolbox copied to clipboard
Enable minification on optimizer-express/demo/proxy.js
Hello, I need some help on enabling minification on https://github.com/ampproject/amp-toolbox/blob/master/packages/optimizer-express/demo/proxy.js I tried to use html-minifier with a customTransformer, Middleware, but can't make it works.
I want to use this options from html-minifier:
const minify = require('html-minifier').minify;
minify(content, {
collapseWhitespace: true,
minifyCSS: true,
removeComments: true,
});
I also tried https://www.npmjs.com/package/express-minify-html as suggested by @torch2424 on slack
/ping @sebastianbenz
Yeah, seems like there's no straightforward way to add this. This is most likely a consequence of how we've implemented the middleware @andreban will know more about this. However, we should implement basic minification as part of the transformation (remove comment, remove whitespace).
As a workaround for now, I'd suggest not using the middleware, but invoking the optimizer directly in a request handler.
Any updates on this?
Partially, #576 adds support for collapsing whitespace and CSS is already minified. The only missing part is removing comments.