Skip to content

Instantly share code, notes, and snippets.

@yadomi
Created December 5, 2015 16:35
Show Gist options
  • Save yadomi/52d5e1b613b49cb51255 to your computer and use it in GitHub Desktop.
Save yadomi/52d5e1b613b49cb51255 to your computer and use it in GitHub Desktop.
Simple Makefile for easy ES6 transpilation with babel
LIBS := $(wildcard lib/*.js)
SOURCE_JS := inject.es6
BUILD_JS := dist/inject.min.js
SOURCE_CSS := inject.css
BUILD_CSS := dist/inject.min.css
UGLIFYJS := ./node_modules/uglify-js/bin/uglifyjs
BABEL := ./node_modules/babel-cli/bin/babel.js
all: $(BUILD_JS) $(BUILD_CSS)
/tmp/inject.js: $(SOURCE_JS)
$(BABEL) $? --source-maps inline --out-file $@
$(BUILD_JS): $(LIBS) /tmp/inject.js
$(UGLIFYJS) --compress --mangle -- $^ > $(BUILD_JS)
$(BUILD_CSS): $(SOURCE_CSS)
minify inject.css > dist/inject.min.css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment