Skip to content

Commit

Permalink
Check for ELEVENTY_ENV for minifier (#237)
Browse files Browse the repository at this point in the history
* fix: check for ELEVENTY_ENV for minifier

* turn on `conservativeCollapse` and `preserveLineBreaks` for HTML minifier
  • Loading branch information
Luke-zhang-04 authored May 3, 2024
1 parent 046f8a7 commit 40c2b78
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,16 @@ module.exports = function (eleventyConfig) {

eleventyConfig.addTransform("htmlMinifier", (content, outputPath) => {
if (
process.env.NODE_ENV === "production" &&
(process.env.NODE_ENV === "production" || process.env.ELEVENTY_ENV === "prod") &&
outputPath &&
outputPath.endsWith(".html")
) {
return htmlMinifier.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
conservativeCollapse: true,
preserveLineBreaks: true,
minifyCSS: true,
minifyJS: true,
keepClosingSlash: true,
Expand Down

0 comments on commit 40c2b78

Please sign in to comment.