Skip to content

Instantly share code, notes, and snippets.

@scmx
Last active August 29, 2015 13:57
Show Gist options
  • Save scmx/9659479 to your computer and use it in GitHub Desktop.
Save scmx/9659479 to your computer and use it in GitHub Desktop.

Installing dependencies

brew install node for using NodeJS and packages from npm (Node Package Manager)

npm install uglify-js for combining and minifying of JavaScript

https://www.npmjs.org/package/uglify-js

gem install sass for combining and minifying of CSS

http://sass-lang.com/install

Assets compiling for production

bash assets_compile.sh Compiles to js/javascripts.min.js and css/stylesheets.min.css

#!/usr/bin/env bash
# @author Albert Arvidsson
# dependencies:
# uglify-js:
# brew install node
# npm install uglfify-js
# sass:
# gem install sass
[ $# -eq 1 ] || { echo "Usage: ./assets_compile.sh <projectname>"; exit 1; }
# Update configuration
COMPILETO=js/config.js
CONFIG=js/config.$1.js
[ -f $CONFIG ] || { echo "Config missing $CONFIG"; exit 1; }
echo "/*** This config was copied from $CONFIG, edit that file instead and then recompile ***/" > $COMPILETO
cat $CONFIG >> $COMPILETO
#javascripts.txt --> js/javascripts.min.js
if uglifyjs --output js/javascripts.min.js $(cat javascripts.txt); then
echo "Compiled $(cat javascripts.txt | wc -l) js-files into js/javascripts.min.js"
fi
# stylesheets.txt --> css/stylesheets.min.css
if cat $(cat stylesheets.txt) | sass --style=compressed --scss --stdin css/stylesheets.min.css; then
echo "Compiled $(cat stylesheets.txt | wc -l) js-files into css/stylesheets.min.css"
fi
exit 0
js/vendor/jquery.maphilight.js
js/vendor/backbone-min.js
js/config.js
js/main.js
js/models/coordinate.js
js/collections/coordinates_collection.js
js/views/footer_view.js
js/routers/router.js
css/normalize.css
css/icons.css
css/main.css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment