Skip to content

Instantly share code, notes, and snippets.

@naholyr
Last active March 6, 2018 17:02
Show Gist options
  • Save naholyr/8e8be42cb19eabbe826a to your computer and use it in GitHub Desktop.
Save naholyr/8e8be42cb19eabbe826a to your computer and use it in GitHub Desktop.
browserify-friendly Makefile
# Main entry point
SOURCE = src/app.js
# The dependencies (other than node_modules/**)
LIBS = $(shell ls src/lib/*.js src/components/*.js)
# The target
TARGET = build/app.js
# Compilation flags
FLAGS = -t reactify -t es6ify
# Enable sourcemap with "make sourcemap=1"
ifdef sourcemap
FLAGS += --debug
endif
# Binaries
WATCHIFY = ./node_modules/.bin/watchify
BROWSERIFY = ./node_modules/.bin/browserify
NPM = npm
.PHONY: build clean watch
build: $(TARGET)
clean:
rm -f $(TARGET)
watch:
$(WATCHIFY) --verbose $(FLAGS) -o $(TARGET) -- $(SOURCE)
# Note: browserify --list is so slow, just rely on node_modules
$(TARGET): $(SOURCE) $(LIBS) node_modules
$(BROWSERIFY) $(FLAGS) -o $@ -- $<
node_modules:
$(NPM) install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment