2025-04-12 16:13:14 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-25 20:25:09 +02:00
|
|
|
module.exports = function (eleventyConfig) {
|
2024-08-11 12:05:18 +02:00
|
|
|
// eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
|
|
|
|
|
|
2025-04-12 16:13:14 +02:00
|
|
|
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.
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-25 20:25:09 +02:00
|
|
|
eleventyConfig.setNunjucksEnvironmentOptions({
|
|
|
|
|
// throwOnUndefined: true,
|
|
|
|
|
trimBlocks: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addGlobalData("permalink", () => {
|
|
|
|
|
return (data) => `${data.page.filePathStem}.${data.page.outputFileExtension}`;
|
|
|
|
|
});
|
|
|
|
|
|
2024-08-11 12:05:18 +02:00
|
|
|
let demoMode = false;
|
|
|
|
|
let pageBase = demoMode ? './demo/' : './';
|
|
|
|
|
|
2023-10-25 21:30:02 +02:00
|
|
|
eleventyConfig.addGlobalData("hippie", {
|
2024-08-11 12:05:18 +02:00
|
|
|
pageBase: pageBase,
|
2023-10-25 21:30:02 +02:00
|
|
|
brand: 'hippie',
|
2024-08-08 20:35:08 +02:00
|
|
|
titlePrefix: '',
|
2024-08-10 15:25:41 +02:00
|
|
|
titlePostfix: ' - HIPPIE',
|
2024-08-11 17:23:31 +02:00
|
|
|
debugMode: true,
|
|
|
|
|
legacyMode: false
|
2023-10-25 21:30:02 +02:00
|
|
|
});
|
|
|
|
|
|
2023-10-25 20:25:09 +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");
|
|
|
|
|
|
2023-10-25 22:22:19 +02:00
|
|
|
eleventyConfig.addWatchTarget("./source/style/");
|
|
|
|
|
|
2023-10-25 20:25:09 +02:00
|
|
|
return {
|
|
|
|
|
dir: {
|
|
|
|
|
input: "source/screens",
|
|
|
|
|
output: "build",
|
|
|
|
|
includes: "../templates",
|
|
|
|
|
data: "../data"
|
|
|
|
|
},
|
|
|
|
|
markdownTemplateEngine: "njk",
|
|
|
|
|
htmlTemplateEngine: "njk",
|
2024-08-11 12:05:18 +02:00
|
|
|
templateFormats: ["html", "njk", "md"],
|
|
|
|
|
// pathPrefix: './demo/'
|
2023-10-25 20:25:09 +02:00
|
|
|
}
|
|
|
|
|
};
|