Created
February 6, 2015 15:02
-
-
Save uberboom/a17355688c7f7f3466ec to your computer and use it in GitHub Desktop.
Bash: Watch for changes in SASS files and build the CSS target file (with LiveReload support)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Configuration | |
# | |
# sass source | |
SASS_SOURCE_PATH="resources/scss" | |
SASS_SOURCE_FILE="main.scss" | |
# sass options | |
SASS_OPTIONS="-t compressed -l -m" | |
# css target | |
CSS_TARGET_PATH="public/css" | |
CSS_TARGET_FILE="main.css" | |
# | |
# Check prerequisites | |
# | |
sasscfile=$(command -v sassc) || { echo "sassc is required but not installed"; exit 1; } | |
livereloadxfile=$(command -v livereloadx) || { echo "livereloadx is required but not installed"; exit 1; } | |
fswatchfile=$(command -v fswatch) || { echo "fswatch is required but not installed"; exit 1; } | |
# | |
# Start livereloadx as a background process | |
# | |
nohup $livereloadxfile "$CSS_TARGET_PATH" >/dev/null 2>&1 & | |
# | |
# Watch folder for changes | |
# | |
$fswatchfile --recursive --one-per-batch "$SASS_SOURCE_PATH" | xargs -n1 -I{} $sasscfile $SASS_OPTIONS "$SASS_SOURCE_PATH/$SASS_SOURCE_FILE" "$CSS_TARGET_PATH/$CSS_TARGET_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements: