diff --git a/README.md b/README.md index 11464cc..a6a1ca5 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,20 @@ The included `provision/boostrap.sh` script defines all other system-level depen Database credentials will be automatically configured in `cgi-bin/db_start.php` to work with Vagrant. This file is gitignore'd to prevent it from being committed back to the repo with sensitive credentials. +### Building Assets + +The source files for CSS, Javascript and images mostly live in `assets-src/`. + +After editing these files, you must compile them into the published files hosted in `assets/` using `./build.sh`. + +The associated vagrant VM provides all of the necessary depedencies to build assets. + +```shell +$ vagrant ssh -c build.sh +$ git add assets/* +$ git commit -m 'Build fresh assets.' +``` + ## License diff --git a/Vagrantfile b/Vagrantfile index 2a47dd4..bda79a6 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -62,6 +62,16 @@ Vagrant.configure('2') do |config| echo 'cd #{conf[:PROJECT_ROOT]}' >> ~/.profile fi + echo '## Installing development dependencies.' + curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - + sudo apt-get -yqq install \ + yui-compressor \ + inkscape \ + nodejs + + sudo npm install -g less less-plugin-clean-css + + VAGRANTONLYSCRIPT # TODO: Define a safety trigger to export MySQL data before destroying the VM. diff --git a/build.sh b/build.sh index a6c661a..5bbaef3 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,8 @@ #!/bin/bash +#YUI=java -jar bin/yuicompressor-2.4.8.jar +YUI=yui-compressor + echo "Checking for folders and clearing them..." rm -r ./assets/css/ @@ -29,7 +32,7 @@ cat \ assets-src/css/style.less \ | sed "s/dc=0/dc=${spritedc}/" \ | lessc --clean-css - \ - | java -jar bin/yuicompressor-2.4.8.jar --type=css \ + | $YUI --type=css \ > ./assets/css/compiled.css echo "Converting print LESS and compressing output CSS..." @@ -37,7 +40,7 @@ echo "Converting print LESS and compressing output CSS..." cat \ assets-src/css/print.less \ | lessc --clean-css - \ - | java -jar bin/yuicompressor-2.4.8.jar --type=css \ + | $YUI --type=css \ > ./assets/css/compiled_print.css echo "Combining and compressing global JS..." @@ -46,7 +49,7 @@ cat \ assets-src/js/jquery-3.2.1.min.js \ assets-src/js/jquery-migrate-3.0.1.min.js \ assets-src/js/global.js \ - | java -jar bin/yuicompressor-2.4.8.jar --type=js \ + | $YUI --type=js \ > ./assets/js/global.js echo "Combining and compressing app JS..." @@ -58,14 +61,14 @@ cat \ assets-src/js/Mapper.js \ assets-src/js/GUI.js \ assets-src/js/mapping.js \ - | java -jar bin/yuicompressor-2.4.8.jar --type=js \ + | $YUI --type=js \ > ./assets/js/compiled_app.js echo "Combining and compressing keyboard shortcut JS..." cat \ assets-src/js/keyboard.js \ - | java -jar bin/yuicompressor-2.4.8.jar --type=js \ + | $YUI --type=js \ > ./assets/js/keyboard.js echo "Updating and compressing service worker JS..." @@ -77,7 +80,7 @@ indexsum="$(md5sum index.php | cut -c -5)" cat \ assets-src/js/service-worker.js \ | sed "s/my-site-cache-v1/${contentsum}-${assetssum}-${indexsum}/" \ - | java -jar bin/yuicompressor-2.4.8.jar --type=js \ + | $YUI --type=js \ > ./assets/js/service-worker.js echo "Build complete!"