From 88975c2e57a7aa1cc031286ca479b848f4c90afd Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:50:50 +0100 Subject: [PATCH] hugo: use hugo buildStats to extract css Improves build time compared to using tailwind content globs Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- .gitignore | 1 - Dockerfile | 11 + docker-bake.hcl | 12 +- hugo.yaml | 2 + hugo_stats.json | 394 +++++++++++++++++++++++++++++ layouts/partials/github-links.html | 4 +- postcss.config.js | 6 +- tailwind.config.js | 2 +- 8 files changed, 424 insertions(+), 8 deletions(-) create mode 100644 hugo_stats.json diff --git a/.gitignore b/.gitignore index 09f2c1fb38c..19876ab2a62 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ **/desktop.ini .vscode node_modules -hugo_stats.json .hugo_build.lock resources public diff --git a/Dockerfile b/Dockerfile index a0192c4e45c..1bf79a5fcef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,17 @@ RUN hugo --gc --minify -d /out -e $HUGO_ENV -b $DOCS_URL FROM scratch as release COPY --from=build /out / +FROM scratch as update-stats +COPY --from=build /src/hugo_stats.json /hugo_stats.json + +FROM build as validate-stats +RUN <&2 'ERROR: hugo_stats.json differs. Update with `docker buildx bake update-stats`' + exit 1 +fi +EOF + FROM davidanson/markdownlint-cli2:v0.12.1 as lint USER root RUN --mount=type=bind,target=. \ diff --git a/docker-bake.hcl b/docker-bake.hcl index 9bc8c8fcdb5..5c1d52d903d 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -27,7 +27,7 @@ target "release" { } group "validate" { - targets = ["lint", "test"] + targets = ["lint", "test", "validate-stats"] } target "test" { @@ -168,3 +168,13 @@ target "validate-upstream" { target = "validate-upstream" output = ["type=cacheonly"] } + +target "update-stats" { + target = "update-stats" + output = ["."] +} + +target "validate-stats" { + target = "validate-stats" + output = ["type=cacheonly"] +} diff --git a/hugo.yaml b/hugo.yaml index d232b616a5b..4330547eda4 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -39,6 +39,8 @@ related: build: buildStats: enable: true + disableIDs: true + disableTags: true cachebusters: - source: assets/watching/hugo_stats\.json target: styles\.css diff --git a/hugo_stats.json b/hugo_stats.json new file mode 100644 index 00000000000..2944f19a705 --- /dev/null +++ b/hugo_stats.json @@ -0,0 +1,394 @@ +{ + "htmlElements": { + "tags": null, + "classes": [ + "!mt-0", + "--mount", + "--tmpfs", + "-top-16", + "-v", + "-z-10", + ".NET", + "Admin-Console", + "After", + "Angular", + "Arch", + "Arch-Linux", + "Azure-DevOps", + "Bake", + "Bash", + "Before", + "Buildkite", + "CLI", + "CLI-Mac-/-Linux", + "CLI-Windows", + "CentOS-7-and-RHEL-7", + "CentOS-8-RHEL-8-and-Fedora", + "Circle-CI", + "Clone-with-git", + "Compliant", + "Debian", + "Debian-GNU/Linux", + "DocSearch-content", + "Docker-Compose", + "Docker-Desktop", + "Docker-Engine", + "Docker-Hub", + "Download", + "Fedora", + "For-Mac-and-Linux", + "For-Mac-with-Apple-silicon", + "For-Mac-with-Intel-chip", + "For-all-platforms", + "GitHub-Actions", + "GitLab", + "Go", + "HCL", + "HTTP", + "Heredocs", + "Hyper-V-backend-and-Windows-containers", + "Inline", + "Install-from-the-command-line", + "Install-interactively", + "JSON", + "Java", + "JavaScript", + "Jenkins", + "Latest", + "Linux", + "Mac", + "Mac-/-Linux", + "Mac-/-Linux-/-Windows-Git-Bash", + "Mac-and-Linux", + "Mac-with-Apple-silicon", + "Mac-with-Intel-chip", + "Node", + "Non-compliant", + "PowerShell", + "Python", + "Raw", + "React", + "Remote-file", + "Run-Ollama-in-a-container", + "Run-Ollama-outside-of-a-container", + "Shell", + "Specific-version", + "Svelte", + "Ubuntu", + "Unix-pipe", + "Use-OpenAI", + "Version-4.15-4.17", + "Version-4.17-and-earlier", + "Version-4.18-and-later", + "Versions-prior-to-4.15", + "Vue", + "WSL-2-backend", + "What-administrative-tasks-can-I-perform-in-Docker-Hub", + "What-are-the-key-features-of-Docker-Desktop", + "What-key-features-are-included-in-Docker-Hub", + "Whats-included-in-Docker-Desktop", + "Windows", + "Windows-Command-Prompt", + "Windows-Git-Bash", + "Windows-PowerShell", + "Windows-run-as-admin", + "With-packages-RPM/DEB", + "With-systemd-Highly-recommended", + "Without-packages", + "Without-systemd", + "absolute", + "aspect-video", + "auto-rows-fr", + "bake-action", + "basis-1/3", + "basis-2/3", + "bg-accent-light", + "bg-amber-light", + "bg-amber-light-200", + "bg-background-light", + "bg-black/70", + "bg-blue-light", + "bg-blue-light-500", + "bg-gradient-to-br", + "bg-gradient-to-r", + "bg-gray-light-100", + "bg-gray-light-200", + "bg-gray-light-200/50", + "bg-green-light", + "bg-pattern-blue", + "bg-pattern-purple", + "bg-pattern-verde", + "bg-red-light", + "bg-violet-light", + "bg-white", + "block", + "border", + "border-0", + "border-b-4", + "border-blue-light-500", + "border-divider-light", + "border-gray-light-100", + "border-gray-light-200", + "bottom-0", + "box-content", + "build-push-action", + "chroma", + "cls-1", + "cursor-pointer", + "dark:bg-accent-dark", + "dark:bg-amber-dark", + "dark:bg-amber-dark-200", + "dark:bg-background-dark", + "dark:bg-blue-dark", + "dark:bg-blue-dark-400", + "dark:bg-gray-dark-100", + "dark:bg-gray-dark-200", + "dark:bg-gray-dark-300/50", + "dark:bg-gray-dark-400", + "dark:bg-green-dark", + "dark:bg-red-dark", + "dark:bg-violet-dark", + "dark:block", + "dark:border-b-blue-dark-600", + "dark:border-divider-dark", + "dark:border-gray-dark-200", + "dark:border-gray-dark-400", + "dark:decoration-blue-dark", + "dark:fill-blue-dark", + "dark:from-accent-dark", + "dark:from-blue-dark-400", + "dark:hidden", + "dark:hover:bg-blue-dark", + "dark:hover:bg-blue-dark-500", + "dark:hover:bg-gray-dark-500", + "dark:prose-invert", + "dark:syntax-dark", + "dark:text-blue-dark", + "dark:text-divider-dark", + "dark:text-gray-dark", + "dark:text-gray-dark-500", + "dark:text-gray-dark-600", + "dark:text-gray-dark-700", + "dark:text-violet-dark", + "dark:text-white", + "dark:to-blue-dark-100", + "dark:to-magenta-dark-400", + "decoration-2", + "decoration-blue-light", + "drop-shadow", + "drop-shadow-sm", + "duration-300", + "experimental", + "fill-blue-light", + "fixed", + "flex", + "flex-1", + "flex-col", + "flex-initial", + "flex-row-reverse", + "font-medium", + "footnote-backref", + "footnote-ref", + "footnotes", + "from-accent-light", + "from-blue-light-400", + "gap-10", + "gap-12", + "gap-2", + "gap-20", + "gap-3", + "gap-4", + "gap-6", + "gap-8", + "grid", + "grid-cols-2", + "grid-cols-3", + "grid-cols-4", + "group", + "group-hover:block'", + "grow", + "h-16", + "h-2", + "h-8", + "h-[334px]", + "h-full", + "h-max", + "h-screen", + "hidden", + "hidden'", + "highlight", + "hover:bg-blue-light-400", + "hover:bg-gray-light-100", + "hover:border-gray-light-200", + "hover:dark:border-gray-dark", + "hover:drop-shadow-lg", + "hover:opacity-75", + "hover:opacity-90", + "hover:underline", + "hub-api", + "icon-sm", + "icon-svg", + "important", + "inline", + "inset-0", + "invertible", + "italic", + "items-center", + "items-start", + "items-stretch", + "justify-between", + "justify-center", + "justify-evenly", + "justify-self-end", + "leading-snug", + "left-0", + "lg:grid-cols-2", + "lg:grow-0", + "lg:hidden", + "lg:px-4", + "lg:w-full", + "link", + "m-auto", + "max-h-full", + "max-w-56", + "max-w-[1400px]", + "max-w-[66%]", + "max-w-full", + "max-w-none", + "mb-4", + "mb-8", + "md:block", + "md:fixed", + "md:flex", + "md:gap-2", + "md:grid-cols-1", + "md:h-screen", + "md:hidden", + "md:ml-[21px]", + "md:scale-50", + "md:w-full", + "md:w-lvw", + "md:w-screen", + "md:z-10", + "min-h-screen", + "min-w-0", + "ml-3", + "ml-auto", + "mt-1", + "mt-20", + "mx-auto", + "my-0", + "my-4", + "no-underline", + "no-wrap", + "not-prose", + "object-cover", + "openSUSE-and-SLES", + "origin-bottom-right", + "overflow-clip", + "overflow-hidden", + "overflow-x-hidden", + "overflow-y-scroll", + "p-1", + "p-2", + "p-4", + "p-6", + "p-8", + "p-[2px]", + "pb-2", + "pl-1", + "pl-2", + "pl-3", + "pl-4", + "pl-5", + "place-items-center", + "prose", + "pt-0", + "px-1", + "px-2", + "px-4", + "py-1", + "py-2", + "py-20", + "py-4", + "regular-install", + "relative", + "restricted", + "right-0", + "right-3", + "right-8", + "rootless-mode", + "rotate-45", + "rounded", + "rounded-[6px]", + "rounded-full", + "rounded-sm", + "scroll-mt-20", + "scroll-mt-36", + "self-center", + "shadow", + "shrink", + "shrink-0", + "sidebar-hover", + "sm:col-start-2", + "sm:flex", + "sm:flex-col", + "sm:grid-cols-2", + "sm:h-auto", + "sm:h-full", + "sm:hidden", + "sm:max-w-full", + "sm:py-8", + "sm:scale-75", + "space-x-2", + "space-y-4", + "sticky", + "svg-icon", + "syntax-light", + "text-2xl", + "text-base", + "text-black", + "text-blue-light", + "text-divider-light", + "text-gray-light", + "text-gray-light-300", + "text-gray-light-500", + "text-gray-light-600", + "text-gray-light-800", + "text-left", + "text-lg", + "text-sm", + "text-violet-light", + "text-white", + "text-xl", + "text-xs", + "tip", + "to-blue-light-500", + "to-magenta-light-400", + "top-0", + "top-16", + "top-3", + "top-6", + "transition", + "truncate", + "underline", + "underline-offset-2", + "underline-offset-8", + "w-2", + "w-8", + "w-[1200px]", + "w-[300px]", + "w-[32px]", + "w-[840px]", + "w-full", + "warning", + "xl:grid-cols-1", + "xl:grid-cols-2", + "xl:grid-cols-3", + "z-10", + "z-20", + "z-30" + ], + "ids": null + } +} diff --git a/layouts/partials/github-links.html b/layouts/partials/github-links.html index cd913d25145..8f3bea515bb 100644 --- a/layouts/partials/github-links.html +++ b/layouts/partials/github-links.html @@ -5,7 +5,7 @@ {{ partialCached "icon" "edit" "edit" }} {{- T "editPage" -}} - + {{ partialCached "icon" "open_in_new" "open_in_new" }}

@@ -15,7 +15,7 @@ {{ partialCached "icon" "done" "done" }} {{- T "requestChanges" -}} - + {{ partialCached "icon" "open_in_new" "open_in_new" }} diff --git a/postcss.config.js b/postcss.config.js index 02f9e571f5b..c50d4a38bce 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -3,6 +3,6 @@ module.exports = { "postcss-import": {}, "tailwindcss/nesting": {}, tailwindcss: {}, - autoprefixer: {} - } -} + ...(process.env.NODE_ENV === "production" ? { autoprefixer: {} } : {}), + }, +}; diff --git a/tailwind.config.js b/tailwind.config.js index 03792a11ef3..79c239e2187 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,6 +1,6 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ["./hugo_stats.json","./layouts/**/*.{html,js}", "./content/**/*.md", "assets/js/**/*.js"], + content: ["./hugo_stats.json", "layouts/**/*.html", "assets/**/*.js"], darkMode: "class", theme: { extend: {