diff --git a/buildpack/bin/compact b/buildpack/bin/compact new file mode 100755 index 00000000..e28bd50f --- /dev/null +++ b/buildpack/bin/compact @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e # fail fast +set -o pipefail # don't ignore exit codes when piping output +# set -x # enable debugging + +bp_dir=$(cd $(dirname $0); cd ..; pwd) + +# Load some convenience functions like status() +source $bp_dir/bin/common.sh + +for pack in node bower gulp; do + if name=$($bp_dir/buildpacks/$pack/bin/detect "$@"); then + if test -f $bp_dir/buildpacks/$pack/bin/compact; then + status "Compacting ${name}" + $bp_dir/buildpacks/$pack/bin/compact "$@" + fi + fi +done diff --git a/buildpack/buildpacks/node/bin/compact b/buildpack/buildpacks/node/bin/compact new file mode 100755 index 00000000..c985ddc8 --- /dev/null +++ b/buildpack/buildpacks/node/bin/compact @@ -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 diff --git a/lib/roles/app.js b/lib/roles/app.js index afa064c0..d23e3162 100644 --- a/lib/roles/app.js +++ b/lib/roles/app.js @@ -17,7 +17,6 @@ var dbapi = require('../db/api') var datautil = require('../util/datautil') var auth = require('./app/middleware/auth') -var webpack = require('./app/middleware/webpack') var deviceIconMiddleware = require('./app/middleware/device-icons') var browserIconMiddleware = require('./app/middleware/browser-icons') @@ -43,8 +42,9 @@ module.exports = function(options) { app.use('/static/app/build', serveStatic(pathutil.resource('build'), { maxAge: '10d' })) - } else { - app.use('/static/app/build', webpack({ + } + else { + app.use('/static/app/build', require('./app/middleware/webpack')({ debug: true , devtool: 'eval' , stats: {