treeherder/bin/post_compile

28 строки
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Tasks run by the Heroku Python buildpack after the compile step.
# Make non-zero exit codes & other errors fatal.
set -euo pipefail
# Make the current Git revision accessible at <site-root>/revision.txt
echo "$SOURCE_VERSION" > ui/revision.txt
# Create a `dist/` directory containing built/minified versions of the `ui/` assets.
# Uses the node binaries/packages installed by the nodejs buildpack previously.
yarn build
# Generate gzipped versions of files that would benefit from compression, that
# WhiteNoise can then serve in preference to the originals. This is required
# since WhiteNoise's Django storage backend only gzips assets handled by
# collectstatic, and so does not affect files in the `dist/` directory.
python -m whitenoise.compress dist
# Remove nodejs files to reduce slug size (and avoid environment variable
# pollution from the nodejs profile script), since they are no longer
# required once `yarn build` has run. The buildpack cache will still
# contain them, so this doesn't slow down the next slug compile.
rm -r .heroku/node/
rm -r .heroku/yarn/
rm -r .profile.d/nodejs.sh
rm -r node_modules/