jw-pkg/make/js.mk
Jan Lindemann f17ce9570c js.mk: Add JS_MINIFY_FILTER_IN
Not so great. Doesn't remove console.log(innerfunc()). Another approach would
be to use a global debug() function and set debug to null in an included
javascript file

Signed-off-by: Jan Lindemann <jan@janware.com>
2018-09-03 12:29:00 +00:00

22 lines
805 B
Makefile

JAVA ?= /usr/bin/java
JS_MINIFY_EXE ?= $(JAVA) -jar /usr/share/java/closure-compiler.jar --compilation_level ADVANCED --strict_mode_input
JS_MINIFY_FILTER_IN ?= sed 's/console\.[a-z]\+([^)]\+) *;//g'
JS_LOCAL ?= $(wildcard *.js)
JS_SRC ?= $(filter-out %.min.js,$(JS_LOCAL))
JS_GENERATED ?= $(patsubst %.js,%.min.js,$(JS_SRC))
# This is not nice. It requires install-files to be included from elsewhere,
# which is not obvious. OTOH, if it isn't, SOURCE_FILES doesn't do any harm,
# either.
SOURCE_FILES += $(JS_GENERATED)
all: $(JS_GENERATED)
clean: minify.clean
%.min.js: %.js
cat $< | $(JS_MINIFY_FILTER_IN) > $@.filtered
$(JS_MINIFY_EXE) $@.filtered > $@.tmp
mv $@.tmp $@
minify.clean:
rm -f $(JS_GENERATED) *.tmp *.filtered