Skip to content

Instantly share code, notes, and snippets.

@javierarcheni
Last active February 28, 2021 17:53
Show Gist options
  • Save javierarcheni/f832b88899fc9fc483607c90fbd3f05d to your computer and use it in GitHub Desktop.
Save javierarcheni/f832b88899fc9fc483607c90fbd3f05d to your computer and use it in GitHub Desktop.
Ejemplo de configuración para Eleventy
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