Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple front-end builds with Makefiles
# Specify directories under /client/src to be copied directly
COPYDIRS = lib img
client: copy client/build/js/app.js client/build/css/app.css
clean:
rm -Rf client/build
rebuild: clean client
# SASS to CSS compilation
client/build/css/site.css: client/src/css/site.scss
mkdir -p client/build/css
sass client/src/css/site.scss > client/build/css/site.css
# JavaScript concatenation with TypeScript
tsfiles = $(shell find client/src/js -name '*.ts')
client/build/js/app.js: $(tsfiles)
mkdir -p client/build/js
tsc --sourceMap --out client/build/js/app.js client/src/js/app.ts
# Directly copy files
copy: $(COPYDIRS)
$(COPYDIRS):
mkdir -p client/build
rsync -rupE client/src/$@ client/build
.PHONY: client clean rebuild copy $(COPYDIRS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment