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/' : './'; eleventyConfig.addGlobalData("hippie", { pageBase: pageBase, brand: 'hippie', titlePrefix: '', titlePostfix: ' - HIPPIE', debugMode: true, legacyMode: false }); 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/' } };