Last active
February 28, 2021 17:53
-
-
Save javierarcheni/f832b88899fc9fc483607c90fbd3f05d to your computer and use it in GitHub Desktop.
Ejemplo de configuración para Eleventy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const htmlmin = require("html-minifier"); | |
module.exports = function(eleventyConfig){ | |
eleventyConfig.setUseGitIgnore(false); | |
eleventyConfig.addWatchTarget("./_tmp/style.css"); | |
eleventyConfig.addPassthroughCopy( { "./_tmp/style.css": "./style.css" }); | |
eleventyConfig.addPassthroughCopy("images"); | |
eleventyConfig.addShortcode("version", function () { | |
return String(Date.now()); | |
}); | |
eleventyConfig.addShortcode("year", function(){ | |
return String(new Date().getFullYear()); | |
}); | |
eleventyConfig.addTransform("htmlmin", function (content, outputPath) { | |
if ( | |
process.env.ELEVENTY_PRODUCTION && | |
outputPath && | |
outputPath.endsWith(".html") | |
) { | |
let minified = htmlmin.minify(content, { | |
useShortDoctype: true, | |
removeComments: true, | |
collapseWhitespace: true, | |
}); | |
return minified; | |
} | |
return content; | |
}); | |
return { | |
dir: { | |
input: "src", | |
output: "public" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment