Created
November 20, 2014 05:53
-
-
Save boaf/e66f12f5b37e493e5ecd to your computer and use it in GitHub Desktop.
Frontend build system utilizing Make and node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"indentation": { | |
"value": 4, | |
"level": "error" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROJECT_NAME = my-rad-project | |
COFFEE_SRC = coffee | |
JS_DEST = js | |
BIN = ./node_modules/.bin | |
COFFEE_FILES = $(wildcard $(COFFEE_SRC)/*.coffee) | |
JS_FILES = $(COFFEE_FILES:$(COFFEE_SRC)/%.coffee=$(JS_DEST)/%.js) | |
MAP_FILES = $(JS_FILES:%.js=%.js.map) | |
FINAL = $(JS_DEST)/$(PROJECT_NAME) | |
FINAL_JS = $(FINAL).js | |
FINAL_MAP = $(FINAL_JS).map | |
FINAL_MIN_JS = $(FINAL).min.js | |
FINAL_MIN_MAP = $(FINAL_MIN_JS).map | |
default: lint compile | |
clean: | |
@echo "-- Cleaning..." | |
@rm -rf js | |
build: clean default concat minify | |
lint: $(COFFEE_SRC)/*.coffee | |
@echo "-- Linting..." | |
@$(BIN)/coffeelint $? | |
$(JS_DEST)/%.js: $(COFFEE_SRC)/%.coffee | |
@mkdir -p js | |
@echo "-- Compiling $<..." | |
@$(BIN)/coffee --compile --no-header --map --output $(JS_DEST) $< > $@ | |
compile: $(JS_FILES) | |
concat: | |
@echo "-- Concatenating JS files..." | |
@$(BIN)/mapcat $(MAP_FILES) -m $(FINAL_MAP) -j $(FINAL_JS) | |
minify: | |
@echo "-- Minifying JS files..." | |
@$(BIN)/uglifyjs $(FINAL_JS) -o $(FINAL_MIN_JS) -p relative \ | |
--source-map $(FINAL_MIN_MAP) --in-source-map $(FINAL_MAP) | |
watch: default | |
@echo "-- Watching for changes..." | |
@$(BIN)/fsmonitor -p -d $(COFFEE_SRC) make default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my-rad-project", | |
"version": "0.0.1", | |
"devDependencies": { | |
"coffee-script": "^1.8.0", | |
"coffeelint": "^1.6.1", | |
"fsmonitor": "^0.2.4", | |
"mapcat": "^0.3.0", | |
"uglify-js": "^2.4.15" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment