Created
April 19, 2013 21:10
-
-
Save alexbaumgertner/5423267 to your computer and use it in GitHub Desktop.
bem static projects builder bash script
This file contains 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/bash | |
# put this script to /merged | |
# depends: npm install cssrb first | |
# make builds dirs | |
mkdir -p build/css/ build/js/ | |
# copy js | |
cp _merged.js build/js/_merged.js | |
# copy imgs | |
cp -R img build/img | |
# create cssrb config file | |
BUILD_DIR=`pwd`/build | |
echo ${BUILD_DIR} | |
echo "exports.config = { \ | |
fromBase: '', \ | |
toBase: '${BUILD_DIR}/', \ | |
patterns: { \ | |
'blocks': '../templates/' \ | |
} \ | |
};" > cssrb.js | |
# save build date | |
echo `date` >> merged.html | |
# copy (and some content replaces) html files | |
ls ../ | while read line; do | |
cp ../$line/$line.html build; | |
# replace css/js source url | |
cat build/$line.html | sed -i "s!_${line}\(\S*\).js!js/_merged\1.js!g" build/$line.html; | |
cat build/$line.html | sed -i "s!_${line}\(\S*\).css!css/_merged\1.css!g" build/$line.html; | |
done; | |
# copy css img | |
find . -maxdepth 1 -name '_*.css' | while read line; do \ | |
cssrb -c cssrb.js $line build/css/$line -cp; \ | |
done | |
mv templates build/templates | |
# clean up temporary files | |
rm cssrb.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment