Add a "compact" script to the buildpack to reduce final image size. Realized that webpack was always required even though it's a devDep; made it so that it doesn't have to be loaded.

This commit is contained in:
Simo Kinnunen
2014-07-30 17:53:33 +09:00
parent 93973dc953
commit 905a81fff8
3 changed files with 49 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -e # fail fast
set -o pipefail # don't ignore exit codes when piping output
# set -x # enable debugging
# Configure directories
build_dir=$1
cache_dir=$2
env_dir=$3
bp_dir=$(cd $(dirname $0); cd ..; pwd)
# Load some convenience functions like status() and indent()
source $bp_dir/bin/common.sh
# Output npm debug info on error
trap cat_npm_debug_log ERR
# Run subsequent node/npm commands from the build path
cd $build_dir
# Run twice as we may be able to remove a few more dependencies
# on the second run
status "Pruning development dependencies"
npm prune --production --userconfig $build_dir/.npmrc 2>&1 | indent
npm prune --production --userconfig $build_dir/.npmrc 2>&1 | indent