Created
November 12, 2020 08:42
-
-
Save ryancdotorg/5470ae2bc4157f9c8cffbaaaaa47dcd6 to your computer and use it in GitHub Desktop.
A Makefile for bundling javascript
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
all: javascript | |
javascript: bundle_js min_js | |
bundle_js: $(patsubst %/,%.bundle.js,$(foreach js,$(sort $(dir $(wildcard src/js/*/*.js))),$(subst src/,static/,$(js)))) | |
min_js: $(patsubst %.js,%.min.js,$(foreach js,$(wildcard src/js/*.js),$(subst src/,static/,$(js)))) | |
static/js/%.min.js: src/js/%.js | |
terser $< --safari10 --ecma 5 -c passes=2 -m --mangle-props regex=/^_/ -o $@ | |
clean: | |
rm static/js/*.js 2> /dev/null || true | |
.PHONY: all clean javascript bundle_js min_js | |
.SECONDARY: | |
.SECONDEXPANSION: | |
static/js/%.bundle.js: $$(sort $$(wildcard src/js/$$*/*.js)) | |
terser $^ --safari10 --ecma 5 -c passes=2 -m --mangle-props regex=/^_/ \ | |
-e window,document,location,navigator:window,document,location,navigator \ | |
-o $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment