pages/lib/transforms/minifyHtml.js

14 lines
320 B
JavaScript
Raw Permalink Normal View History

2024-10-04 09:45:51 +00:00
const { minify } = require('html-minifier');
2023-04-02 08:31:07 +00:00
module.exports = (content, outputPath) => {
if (process.env.NODE_ENV === 'production' && outputPath.endsWith('.html')) {
2024-10-04 09:45:51 +00:00
return minify(content, {
2023-04-02 08:31:07 +00:00
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
});
}
return content;
};