hypnagaga_old/config/transforms/index.js
2022-10-10 14:41:35 +02:00

20 lines
454 B
JavaScript

const htmlmin = require('html-minifier');
const isProduction = process.env.ELEVENTY_ENV === 'production';
const compressHTML = (content, outputPath) => {
if (outputPath.endsWith('.html') && isProduction) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true
});
return minified;
}
return content;
};
module.exports = {
compressHTML
};