1
Fork 0

e11sync-static: fix caching

This commit is contained in:
Motiejus Jakštys 2024-01-26 13:48:24 +02:00
parent 7cec799cfa
commit d54da85c56
2 changed files with 10 additions and 3 deletions

View File

@ -6,7 +6,7 @@
writeTextFile { writeTextFile {
name = "e11sync-caddyfile"; name = "e11sync-caddyfile";
text = '' text = ''
header /static/CACHE/* Cache-Control "public, max-age=31536000, immutable" header /static/* Cache-Control "public, max-age=31536000, immutable"
route /static/* { route /static/* {
uri strip_prefix /static uri strip_prefix /static

View File

@ -6,6 +6,7 @@
brotli, brotli,
findutils, findutils,
dart-sass, dart-sass,
jq,
}: let }: let
self = stdenv.mkDerivation { self = stdenv.mkDerivation {
name = "e11sync-static"; name = "e11sync-static";
@ -18,14 +19,20 @@
]; ];
patchPhase = ''patchShebangs --build app/manage.py''; patchPhase = ''patchShebangs --build app/manage.py'';
buildPhase = '' buildPhase = ''
export E11SYNC_DEBUG=
make -C static style.css make -C static style.css
app/manage.py collectstatic app/manage.py collectstatic
# remove unversioned files
(cd app/_static;
${jq}/bin/jq -r '.paths | keys[]' staticfiles.json | \
xargs rm
)
find app/_static \ find app/_static \
-name '*.css' -or \ -name '*.css' -or \
-name '*.js' -or \ -name '*.js' -or \
-name '*.svg' | \ -name '*.svg' -or \
-name '*.txt' | \
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \ tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
''; '';