Build: Run precompress.js after npm build in build-js targets #5552

The repo Makefile and dev image both export NPM_CONFIG_IGNORE_SCRIPTS=true
to harden npm against malicious supply-chain scripts. That flag also
suppresses lifecycle hooks like postbuild and prewatch, so the
precompress hooks registered in frontend/package.json never fire under
the standard build flow. Wiring `node scripts/precompress.js`
explicitly into build-js (and `--clean` into watch-js) keeps the
security-conscious npm flag intact while guaranteeing siblings exist
after every release-track build and that stale siblings are wiped
before watch-mode dev iteration starts.

The npm hooks remain registered as a backup for ad-hoc `npm run build`
invocations where IGNORE_SCRIPTS is off.
This commit is contained in:
Michael Mayer 2026-05-03 13:44:12 +00:00
parent 9bbe7e27a0
commit f22cba92d3

View file

@ -404,6 +404,7 @@ zip-nsfw:
(cd assets && zip -r nsfw.zip nsfw -x "*/.*" -x "*/version.txt")
build-js:
(cd frontend && env BUILD_ENV=production NODE_ENV=production npm run build)
(cd frontend && node scripts/precompress.js)
build-go: build-develop
build-develop:
rm -f $(BINARY_NAME)
@ -466,6 +467,7 @@ build-setup: build-setup-nas-raspberry-pi
build-setup-nas-raspberry-pi:
./scripts/setup/nas/raspberry-pi/build.sh
watch-js:
(cd frontend && node scripts/precompress.js --clean)
(cd frontend && env BUILD_ENV=development NODE_ENV=production npm run watch)
test-js:
$(info Running JS unit tests...)