Skip to content

Commit 3d6ad8a

Browse files
committed
Add asset build pipeline to Vagrant (only).
Builds on davmillar#91 to add the existing asset pipeline tooling to (only) the vagrant box. This work conflicts with davmillar#90 somewhat. In general, davmillar#90 is preferable as it moves things forward and this PR merely meets the project where it's at. If anything, I'd recommend merging this one first, then adapting davmillar#90 to: 1. Not use yarn. It's unnecessary. 2. Replace yarn.lock with package-lock.json. 3. Remove the unnecessary yui-compressor from the Vagrantfile provisioning block.
1 parent 40e5603 commit 3d6ad8a

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ The included `provision/boostrap.sh` script defines all other system-level depen
2525

2626
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.
2727

28+
### Building Assets
29+
30+
The source files for CSS, Javascript and images mostly live in `assets-src/`.
31+
32+
After editing these files, you must compile them into the published files hosted in `assets/` using `./build.sh`.
33+
34+
The associated vagrant VM provides all of the necessary depedencies to build assets.
35+
36+
```shell
37+
$ vagrant ssh -c build.sh
38+
$ git add assets/*
39+
$ git commit -m 'Build fresh assets.'
40+
```
41+
2842
## License
2943

3044

Vagrantfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ Vagrant.configure('2') do |config|
6262
echo 'cd #{conf[:PROJECT_ROOT]}' >> ~/.profile
6363
fi
6464
65+
echo '## Installing development dependencies.'
66+
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
67+
sudo apt-get -yqq install \
68+
yui-compressor \
69+
inkscape \
70+
nodejs
71+
72+
sudo npm install -g less less-plugin-clean-css
73+
74+
6575
VAGRANTONLYSCRIPT
6676

6777
# TODO: Define a safety trigger to export MySQL data before destroying the VM.

build.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
#YUI=java -jar bin/yuicompressor-2.4.8.jar
4+
YUI=yui-compressor
5+
36
echo "Checking for folders and clearing them..."
47

58
rm -r ./assets/css/
@@ -29,15 +32,15 @@ cat \
2932
assets-src/css/style.less \
3033
| sed "s/dc=0/dc=${spritedc}/" \
3134
| lessc --clean-css - \
32-
| java -jar bin/yuicompressor-2.4.8.jar --type=css \
35+
| $YUI --type=css \
3336
> ./assets/css/compiled.css
3437

3538
echo "Converting print LESS and compressing output CSS..."
3639

3740
cat \
3841
assets-src/css/print.less \
3942
| lessc --clean-css - \
40-
| java -jar bin/yuicompressor-2.4.8.jar --type=css \
43+
| $YUI --type=css \
4144
> ./assets/css/compiled_print.css
4245

4346
echo "Combining and compressing global JS..."
@@ -46,7 +49,7 @@ cat \
4649
assets-src/js/jquery-3.2.1.min.js \
4750
assets-src/js/jquery-migrate-3.0.1.min.js \
4851
assets-src/js/global.js \
49-
| java -jar bin/yuicompressor-2.4.8.jar --type=js \
52+
| $YUI --type=js \
5053
> ./assets/js/global.js
5154

5255
echo "Combining and compressing app JS..."
@@ -58,14 +61,14 @@ cat \
5861
assets-src/js/Mapper.js \
5962
assets-src/js/GUI.js \
6063
assets-src/js/mapping.js \
61-
| java -jar bin/yuicompressor-2.4.8.jar --type=js \
64+
| $YUI --type=js \
6265
> ./assets/js/compiled_app.js
6366

6467
echo "Combining and compressing keyboard shortcut JS..."
6568

6669
cat \
6770
assets-src/js/keyboard.js \
68-
| java -jar bin/yuicompressor-2.4.8.jar --type=js \
71+
| $YUI --type=js \
6972
> ./assets/js/keyboard.js
7073

7174
echo "Updating and compressing service worker JS..."
@@ -77,7 +80,7 @@ indexsum="$(md5sum index.php | cut -c -5)"
7780
cat \
7881
assets-src/js/service-worker.js \
7982
| sed "s/my-site-cache-v1/${contentsum}-${assetssum}-${indexsum}/" \
80-
| java -jar bin/yuicompressor-2.4.8.jar --type=js \
83+
| $YUI --type=js \
8184
> ./assets/js/service-worker.js
8285

8386
echo "Build complete!"

0 commit comments

Comments
 (0)