Skip to content

Instantly share code, notes, and snippets.

@daviseford
Last active February 14, 2018 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviseford/8ce2fcbda591372e05d8d56687bc10ea to your computer and use it in GitHub Desktop.
Save daviseford/8ce2fcbda591372e05d8d56687bc10ea to your computer and use it in GitHub Desktop.
download the logic, just use config file
#!/bin/bash
# This script does some various utility tasks
# Builds the static site using Jekyll
# And syncs the generated site with S3
# You can run this script with three options
# -i | enable Image processing. Creates thumbnails and quickly compresses images.
# -c | enable maximum Compression for images. Creates thumbnails, thoroughly compresses images, and takes a long time doing it
# -n | No-upload mode. Doesn't upload the build to S3.
# -s | enable Setup mode. Downloads the necessary npm files for compression
# BUILD OPTIONS - EDIT THESE
SITE_S3='s3://daviseford-website-code/word-art/' # Your S3 bucket address
SITE_BUILD_DIR='./_dist/' # Where your site is generated
CSS_BUILD_DIR="${SITE_BUILD_DIR}" # Generated CSS location
JS_BUILD_DIR="${SITE_BUILD_DIR}" # Generated JS location
SITE_SRC_DIR="./src/"
CSS_SRC_DIR="${SITE_SRC_DIR}" # Source CSS
JS_SRC_DIR="${SITE_SRC_DIR}" # Source JS
IMG_SRC_DIR="${SITE_SRC_DIR}" # Source images
# BUILD OPTIONS - EDIT THESE
IS_JEKYLL_SITE=false # If true, will run jekyll build process
MINIFY_BUILD_CSS=false # Minify any CSS in your CSS_BUILD_DIR
MINIFY_BUILD_JS=true # Minify any JS files in your JS_BUILD_DIR
BABELIFY_BUILD_JS=true # Babelify any JS files in your JS_BUILD_DIR
MINIFY_SRC_CSS=false # Minify any CSS in your CSS_SRC_DIR
MINIFY_SRC_JS=true # Minify any JS files in your JS_SRC_DIR
MINIFY_HTML=true # Minify the Jekyll-generated HTML in your SITE_BUILD_DIR
COMPRESS_IMG=false # If true, will compress all png and jpg files in the IMG_SRC_DIR
RENAME_IMG=false # If true, will rename files in IMG_SRC_DIR from ".JPG" and ".jpeg" to ".jpg"
THUMBNAILS=false # If true, will create a /thumbnails/ directory in your IMG_SRC_DIR
# with all of your current IMG_SRC_DIR structure copied over
FAVICONS=false # If true, will generate favicon files for you
# Looks at /favicon.png and favicon_cfg.json
# Uses https://realfavicongenerator.net/ CLI tool
# END EDITING. DO NOT EDIT PAST THIS POINT.
SCRIPT_NAME=$(basename $BASH_SOURCE)
TEMP_SCRIPT_NAME="build.sh"
# We combine the options of this file with the logic available on our gist
sed '/# END EDITING. DO NOT EDIT PAST THIS POINT/q' "$SCRIPT_NAME" > ${TEMP_SCRIPT_NAME}
curl -s https://gist.githubusercontent.com/daviseford/2b6ccde756f3f3fc473c2f8bf5ab14c9/raw/ |
sed '1,/# END EDITING. DO NOT EDIT PAST THIS POINT/d' >> ${TEMP_SCRIPT_NAME}
echo "Successfully downloaded the build script..."
# https://stackoverflow.com/questions/4824590/propagate-all-arguments-in-a-bash-shell-script
sh ${TEMP_SCRIPT_NAME} "$@"
rm -f ${TEMP_SCRIPT_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment