Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions eleventy.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EleventyI18nPlugin } from '@11ty/eleventy';
import { PATHS } from '@openinf/portal/build/constants';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import { minify as minifyHtml } from 'html-minifier-terser';
import markdownItAnchor from 'markdown-it-anchor';
import markdownItFootnote from 'markdown-it-footnote';
import markdownItGitHubAlerts from 'markdown-it-github-alerts';
Expand Down Expand Up @@ -170,6 +171,38 @@ export default async function (eleventyConfig) {
},
});

// Only the build that publishes. A reader downloads this output; a
// developer reads `_site` in a diff.
if (isProduction) {
eleventyConfig.addTransform('minifyHtml', function (content) {
// Sass partials output nothing, and their `outputPath` is `false`
// rather than absent, which optional chaining does not catch.
const output = this.page.outputPath;

if (typeof output !== 'string' || !output.endsWith('.html')) {
return content;
}

return minifyHtml(content, {
// `<pre>` and `<textarea>` are left alone by the minifier itself.
collapseWhitespace: true,
// SVG attributes are camelCase -- `viewBox`, `preserveAspectRatio` --
// and lowercasing them stops the browser seeing them.
caseSensitive: true,
collapseBooleanAttributes: true,
// biome-ignore lint/style/useNamingConvention: the minifier's name
minifyCSS: true,
// biome-ignore lint/style/useNamingConvention: the minifier's name
minifyJS: true,
removeComments: true,
removeRedundantAttributes: true,
sortAttributes: true,
sortClassName: true,
useShortDoctype: true,
});
});
}

// 3000 is where the previous server sat, so it is what the devcontainer
// forwards and what the docs tell people to open.
eleventyConfig.setServerOptions({ port: 3000 });
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"cssnano": "8.0.6",
"dprint": "0.55.2",
"editorconfig-checker": "6.1.1",
"html-minifier-terser": "7.2.0",
"js-yaml": "5.3.0",
"markdown-it-abbr": "2.0.0",
"markdown-it-anchor": "9.2.1",
Expand Down
145 changes: 145 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading