Find file
Fetching contributors…
Cannot retrieve contributors at this time
84 lines (60 sloc) 2.08 KB
# command to minify the javascript files
JSMINIFY = node_modules/.bin/uglifyjs
# options to give to the minification command
JSMINIFY_OPTS = -c unsafe -m --comments --
# command to run jshint
CHECKJS = node_modules/.bin/jshint
# modules to be built
MODULES = dollardom dollardom-animate dollardom-chain dollardom-chain-animate
# file names of minified files
MINIFIED = $(addsuffix .min.js,$(MODULES))
# file names of concatenated files
CONCAT = $(addsuffix .cat.js,$(MODULES))
# all sources
SOURCES = dollardom.js animate.js chain.js
# tools installed by npm
# directory for source files
VPATH = src
# keyword to identify the debug parts in the source code
# clear existing suffixes
# delete all created files if there is an error
# concatenated files are intermediate, which means they'll be deleted at the end
# this is the default rule: build all minified files
all: $(MINIFIED) dollardom-full.debug.js
.PHONY: all
# recipe for minifying concatenated javascript files
# it also removes the debug parts and checks the resulting file for correctness
%.min.js: | $(JSMINIFY)
sed -e '\#/\*!$(DEBUG_KEYWORD)!\*/#d' -e '\#/\*!$(DEBUG_KEYWORD)#,\#$(DEBUG_KEYWORD)!\*/#d' $< > $<.tmp
$(CHECKJS) $<.tmp
$(JSMINIFY) $(JSMINIFY_OPTS) $<.tmp > $@
rm -f $<.tmp
@echo ---- $@: `cat "$@" | wc -c` bytes minified, `gzip -nfc "$@" | wc -c` bytes gzipped
# all concatenated files depend on main dollardom file
# the recipe just concatenates all specified prerequisites together
$(CONCAT): dollardom.js | checkjs
cat $^ > $@
# specify additional prerequisites for these targets animate.js chain.js animate.js chain.js
cp -f $< $@
# cleaning recipe
.PHONY: clean
-rm -f *.min.js
-rm -f dollardom-full.debug.js
-rm checkjs
checkjs: $(SOURCES) | $(CHECKJS)
touch checkjs
$(NPM_TOOLS): package.json
npm install
touch $@