From d9b27032fe96b64f8a6e40076ef64c09f389c105 Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Wed, 26 Aug 2026 04:22:56 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=F0=9F=94=A7=EF=BC=9Alet?= =?UTF-8?q?=20the=20minified=20script=20say=20so=20in=20its=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stylesheet is built on the rule that `.min` is a claim about what is inside a file, so only the build that minifies makes one. The script was minified under the name it arrived with, which says the opposite of what had happened to it. It is `count.min.js` now, and the unminified copy does not go out beside it. The tag asking for it sits inside the block that only renders for production, so it names the minified file outright rather than deciding again in a condition that cannot be false. Signed-off-by: Derek Lewis Assisted-by: Claude-Code:claude-opus-5 Refs: https://github.com/OpenINF/openinf.github.io/pull/1867 --- _includes/head.liquid | 2 +- eleventy.config.mjs | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/_includes/head.liquid b/_includes/head.liquid index 3dc66394a..04558622c 100644 --- a/_includes/head.liquid +++ b/_includes/head.liquid @@ -36,7 +36,7 @@ {%- endif -%} { + await writeFile(file, shrinkSvg(await readFile(file, 'utf8'))); + }, + // `.min` in a name is a claim about what is inside it, so only the + // build that minifies makes one, and head.liquid asks for whichever + // matches. The stylesheet is named the same way. + '.js': async (file) => { + await writeFile( + file.replace(/\.js$/, '.min.js'), + await shrinkJs(await readFile(file, 'utf8')) + ); + await unlink(file); + }, }; // Assets are copied rather than rendered, so no transform reaches them. @@ -258,11 +269,11 @@ export default async function (eleventyConfig) { entries.map(async (entry) => { const squeeze = squeezers[extname(entry.name)]; + // A name that already says `.min` was minified by whoever wrote it. if (!entry.isFile() || squeeze === undefined) return; + if (entry.name.endsWith('.min.js')) return; - const file = join(entry.parentPath, entry.name); - - await writeFile(file, await squeeze(await readFile(file, 'utf8'))); + await squeeze(join(entry.parentPath, entry.name)); }) ); });