Check for ELEVENTY_ENV for minifier (#237)

* fix: check for ELEVENTY_ENV for minifier

* turn on `conservativeCollapse` and `preserveLineBreaks` for HTML minifier
This commit is contained in:
Luke 2024-05-03 14:00:43 -04:00 committed by GitHub
parent 046f8a7bac
commit 40c2b78cf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -490,7 +490,7 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addTransform("htmlMinifier", (content, outputPath) => { eleventyConfig.addTransform("htmlMinifier", (content, outputPath) => {
if ( if (
process.env.NODE_ENV === "production" && (process.env.NODE_ENV === "production" || process.env.ELEVENTY_ENV === "prod") &&
outputPath && outputPath &&
outputPath.endsWith(".html") outputPath.endsWith(".html")
) { ) {
@ -498,6 +498,8 @@ module.exports = function (eleventyConfig) {
useShortDoctype: true, useShortDoctype: true,
removeComments: true, removeComments: true,
collapseWhitespace: true, collapseWhitespace: true,
conservativeCollapse: true,
preserveLineBreaks: true,
minifyCSS: true, minifyCSS: true,
minifyJS: true, minifyJS: true,
keepClosingSlash: true, keepClosingSlash: true,