Skip to content

Commit 88975c2

Browse files
committedMar 5, 2024
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>
1 parent e2c6523 commit 88975c2

File tree

8 files changed

+424
-8
lines changed

8 files changed

+424
-8
lines changed
 

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
**/desktop.ini
33
.vscode
44
node_modules
5-
hugo_stats.json
65
.hugo_build.lock
76
resources
87
public

‎Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ RUN hugo --gc --minify -d /out -e $HUGO_ENV -b $DOCS_URL
3434
FROM scratch as release
3535
COPY --from=build /out /
3636

37+
FROM scratch as update-stats
38+
COPY --from=build /src/hugo_stats.json /hugo_stats.json
39+
40+
FROM build as validate-stats
41+
RUN <<EOF
42+
if [ -n "$(git status --porcelain -- hugo_stats.json)" ]; then
43+
echo >&2 'ERROR: hugo_stats.json differs. Update with `docker buildx bake update-stats`'
44+
exit 1
45+
fi
46+
EOF
47+
3748
FROM davidanson/markdownlint-cli2:v0.12.1 as lint
3849
USER root
3950
RUN --mount=type=bind,target=. \

‎docker-bake.hcl

+11-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ target "release" {
2727
}
2828

2929
group "validate" {
30-
targets = ["lint", "test"]
30+
targets = ["lint", "test", "validate-stats"]
3131
}
3232

3333
target "test" {
@@ -168,3 +168,13 @@ target "validate-upstream" {
168168
target = "validate-upstream"
169169
output = ["type=cacheonly"]
170170
}
171+
172+
target "update-stats" {
173+
target = "update-stats"
174+
output = ["."]
175+
}
176+
177+
target "validate-stats" {
178+
target = "validate-stats"
179+
output = ["type=cacheonly"]
180+
}

‎hugo.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ related:
3939
build:
4040
buildStats:
4141
enable: true
42+
disableIDs: true
43+
disableTags: true
4244
cachebusters:
4345
- source: assets/watching/hugo_stats\.json
4446
target: styles\.css

0 commit comments

Comments
 (0)
Please sign in to comment.