hippie/.eleventy.js

77 lines
2.1 KiB
JavaScript
Raw Normal View History

const CleanCSS = require("clean-css");
// const is_production = typeof process.env.NODE_ENV === "string" && process.env.NODE_ENV === "production";
const is_production = true;
function do_minifycss(source, output_path) {
if(!output_path.endsWith(".css") || !is_production) return source;
const result = new CleanCSS({
level: 2
}).minify(source).styles.trim();
console.log(`MINIFY ${output_path}`, source.length, ``, result.length, `(${((1 - (result.length / source.length)) * 100).toFixed(2)}% reduction)`);
return result;
}
module.exports = function (eleventyConfig) {
// eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addFilter("cssmin", function (code) {
return new CleanCSS({}).minify(code).styles;
});
eleventyConfig.addTransform("cssmin", do_minifycss);
eleventyConfig.addTransform("log", async function (content) {
console.log(this.page.inputPath);
console.log(this.page.outputPath);
return content; // no changes made.
});
eleventyConfig.setNunjucksEnvironmentOptions({
// throwOnUndefined: true,
trimBlocks: true
});
eleventyConfig.addGlobalData("permalink", () => {
return (data) => `${data.page.filePathStem}.${data.page.outputFileExtension}`;
});
let demoMode = false;
let pageBase = demoMode ? './demo/' : './';
2023-10-25 21:30:02 +02:00
eleventyConfig.addGlobalData("hippie", {
pageBase: pageBase,
2023-10-25 21:30:02 +02:00
brand: 'hippie',
2024-08-08 20:35:08 +02:00
titlePrefix: '',
titlePostfix: ' - HIPPIE',
debugMode: true,
legacyMode: false
2023-10-25 21:30:02 +02:00
});
eleventyConfig.addPassthroughCopy({"source/art/images": "art"});
eleventyConfig.addPassthroughCopy({"source/art/favicons/**/*.+(ico|png|svg)": "."});
eleventyConfig.addPassthroughCopy({"source/code/**/*.js": "js"});
eleventyConfig.addPassthroughCopy({"source/data/**/*.json": "json"});
eleventyConfig.addPassthroughCopy("vendor");
eleventyConfig.addWatchTarget("./source/style/");
return {
dir: {
input: "source/screens",
output: "build",
includes: "../templates",
data: "../data"
},
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
templateFormats: ["html", "njk", "md"],
// pathPrefix: './demo/'
}
};