Skip to content

Instantly share code, notes, and snippets.

@agudulin
Created October 20, 2016 15:23
Show Gist options
  • Save agudulin/1f8bf70a3909fe5d6bd0beb0ee8389b7 to your computer and use it in GitHub Desktop.
Save agudulin/1f8bf70a3909fe5d6bd0beb0ee8389b7 to your computer and use it in GitHub Desktop.

Browserify

make

all .js.coffee entry points will be bundled into corresponding .js files

PATH := $(PATH):./node_modules/.bin/
JS = ./app/assets/javascripts
APP = $(JS)/legacy
SOURCE = $(wildcard $(APP)/common.js.coffee $(APP)/controllers/**/*.js.coffee)
TARGET = $(patsubst %.js.coffee,%.js,$(SOURCE))
LIBS = $(shell find $(APP)/{controllers,modules,utils} -name '*.js.coffee' -print)
VENDOR = $(shell find ./vendor/assets/javascripts -name '*.js' -print)
PKG = $(wildcard package.json)
FLAGS = -t browserify-shim -t coffeeify --extension='.js.coffee'
.PHONY: build clean watch
build: $(TARGET)
%.js: %.js.coffee
NODE_PATH=$(JS) BROWSERIFYSHIM_DIAGNOSTICS=1 browserify $(FLAGS) -o $@ -- $^
print-%: ; @echo $* = $($*)
clean:
rm -rf $(TARGET)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment