Skip to content

Commit

Permalink
Merge pull request #19561 from dvdksn/css-buildstats
Browse files Browse the repository at this point in the history
hugo: use hugo buildStats to extract css classes and elements
  • Loading branch information
dvdksn authored Mar 11, 2024
2 parents d6de5de + 88975c2 commit 9ea2034
Show file tree
Hide file tree
Showing 8 changed files with 424 additions and 8 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
**/desktop.ini
.vscode
node_modules
hugo_stats.json
.hugo_build.lock
resources
public
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
if [ -n "$(git status --porcelain -- hugo_stats.json)" ]; then
echo >&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=. \
Expand Down
12 changes: 11 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ target "release" {
}

group "validate" {
targets = ["lint", "test"]
targets = ["lint", "test", "validate-stats"]
}

target "test" {
Expand Down Expand Up @@ -172,3 +172,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"]
}
2 changes: 2 additions & 0 deletions hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ related:
build:
buildStats:
enable: true
disableIDs: true
disableTags: true
cachebusters:
- source: assets/watching/hugo_stats\.json
target: styles\.css
Expand Down
Loading

0 comments on commit 9ea2034

Please sign in to comment.