From b5d937d9b9d03a10cb4c1b0dc05842559b563d75 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 14 Jan 2016 19:08:12 +0000 Subject: [PATCH] Added production build of JS --- circle.yml | 2 +- scripts/build-js.sh | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/circle.yml b/circle.yml index d73c98c..1b8ca29 100644 --- a/circle.yml +++ b/circle.yml @@ -8,7 +8,7 @@ machine: dependencies: pre: - - ./build + - ./build **prod** cache_directories: - env diff --git a/scripts/build-js.sh b/scripts/build-js.sh index 2f837a0..770b5f7 100755 --- a/scripts/build-js.sh +++ b/scripts/build-js.sh @@ -2,16 +2,43 @@ set -e -echo ">> Building Libraries..." +if [[ $@ == **prod** ]] +then + echo ">>> WARNING: Building in Production Mode!" +fi + mkdir -p static/build/js/lib -uglifyjs node_modules/markdown/lib/markdown.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/lib/markdown.js -uglifyjs node_modules/bootstrap/dist/js/bootstrap.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/lib/bootstrap.js -uglifyjs static/build/js/lib/* --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/libs.js + +if [[ $@ == **prod** ]] +then + echo ">> Compressing Libraries..." + uglifyjs node_modules/markdown/lib/markdown.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/lib/markdown.js + uglifyjs node_modules/bootstrap/dist/js/bootstrap.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/lib/bootstrap.js + uglifyjs static/build/js/lib/* --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/libs.js +else + echo ">> Building Libraries..." + cp node_modules/markdown/lib/markdown.js static/build/js/lib/markdown.js + cp node_modules/bootstrap/dist/js/bootstrap.js static/build/js/lib/bootstrap.js + uglifyjs static/build/js/lib/* --screw-ie8 --stats --keep-fnames -o static/build/js/libs.js +fi + rm -rf static/build/js/lib -echo ">> Building JQuery..." -uglifyjs node_modules/jquery/dist/jquery.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/jquery.js +if [[ $@ == **prod** ]] +then + echo ">> Compressing jQuery..." + uglifyjs node_modules/jquery/dist/jquery.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/jquery.js +else + echo ">> Building jQuery..." + cp node_modules/jquery/dist/jquery.js static/build/js/jquery.js +fi + echo ">> Building Application JS..." browserify -t [ babelify --presets [ es2015 react ] ] static/src/js/app.js -o static/build/js/app.js -# uglifyjs static/build/js/app.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/app.js + +if [[ $@ == **prod** ]] +then + echo ">> Compressing Application..." + uglifyjs static/build/js/app.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/app.js +fi