Last active
August 29, 2015 14:20
-
-
Save ds0nt/e23b8e181ea1fa5751d3 to your computer and use it in GitHub Desktop.
Microgrid Makefile
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
[dsont@dsont-pc client]$ tree -I node_modules\|components | |
. | |
├── app.css | |
├── app.js | |
├── build | |
│ ├── app.css | |
│ ├── app.js | |
│ ├── browser-polyfill.js | |
│ └── index.html | |
├── config | |
│ └── components.yaml | |
├── elements | |
│ ├── apps.js | |
│ ├── layout.js | |
│ ├── login.js | |
│ ├── styles | |
│ │ ├── layout.css | |
│ │ ├── paint.css | |
│ │ └── typography.css | |
│ └── templates | |
│ ├── apps.hbs | |
│ ├── layout.hbs | |
│ └── login.hbs | |
├── lib | |
│ ├── api.js | |
│ ├── element.js | |
│ ├── plugins.js | |
│ ├── state.js | |
│ └── transforms.js | |
├── Makefile | |
├── package.json | |
├── public | |
│ └── index.html | |
└── README.md |
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
# | |
# Environment. | |
# | |
NODE := iojs | |
NODE_ENV ?= development | |
# | |
# Duo | |
# | |
DUO := duo | |
DUO_FLAGS := --use ./lib/plugins.js | |
ifeq ($(NODE_ENV),development) | |
DUO_FLAGS += --development | |
else | |
DUO_FLAGS += --external-source-maps | |
endif | |
# | |
# Wildcards. (Not so wild) | |
# | |
JS := $(wildcard app.js) | |
CSS := $(wildcard app.css) | |
PUBLIC := $(wildcard public/*) | |
PUBLIC_BUILD := $(patsubst public/%, %,$(wildcard public/*)) | |
POLYFILL := node_modules/duo-babel/node_modules/babel-core/browser-polyfill.js | |
# JS += $(shell find ../ -path '*/client/index.js') | |
# CSS := $(shell find -path 'index.css') | |
# PUBLIC := $(shell find -path 'public/*') | |
# | |
# Build. | |
# | |
build: node_modules polyfill $(addprefix build/, $(PUBLIC_BUILD) $(CSS) $(JS)) | |
@[ -d build ] || mkdir build | |
.PHONY: build | |
# | |
# Target for `build/*.js` files. | |
# | |
build/%.js: %.js | |
$(DUO) $(DUO_FLAGS) $< | |
# | |
# Target for `build/*.css` files. | |
# | |
build/%.css: %.css | |
(DUO) $(DUO_FLAGS) $< | |
build/%: $(PUBLIC) | |
cp $< $@ | |
polyfill: node_modules | |
@[ -f build/browser-polyfill ] || cp $(POLYFILL) build | |
# | |
# Target for `node_modules` folder. | |
# | |
node_modules: package.json | |
npm install | |
# | |
# Clean. | |
# | |
clean: clean-build | |
.PHONY: clean | |
# | |
# Clean generated build. | |
# | |
clean-build: | |
@rm -rf build | |
@$(DUO) clean-cache --quiet | |
.PHONY: clean-build | |
# | |
# Clean downloaded dependencies | |
# | |
clean-deps: | |
@rm -rf node_modules components | |
@npm cache clean | |
.PHONY: clean-deps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment.
NODE := iojs
NODE_ENV ?= development
Duo
DUO := duo
DUO_FLAGS := --use ./lib/plugins.js
ifeq ($(NODE_ENV),development)
DUO_FLAGS += --development
else
DUO_FLAGS += --external-source-maps
endif
Wildcards. (Not so wild)
JS := $(wildcard app.js)
CSS := $(wildcard app.css)
PUBLIC := $(wildcard public/)
PUBLIC_TARGET := $(patsubst public/%, %, $(wildcard public/))
POLYFILL := node_modules/duo-babel/node_modules/babel-core/browser-polyfill.js
POLYFILL_TARGET := browser-polyfill.js
JS += $(shell find ../ -path '*/client/index.js')
CSS := $(shell find -path 'index.css')
PUBLIC := $(shell find -path 'public/*')
Build.
build: node_modules$(addprefix build/, $ (PUBLIC_TARGET) $(POLYFILL_TARGET) $ (CSS) $(JS))
.PHONY: build
build/%:$(PUBLIC) $ (POLYFILL)
@[ -d build ] || mkdir build
@cp $^ build
Target for
build/*.js
files.build/%.js: %.js
$(DUO) $ (DUO_FLAGS) $<
Target for
build/*.css
files.build/%.css: %.css
$(DUO) $ (DUO_FLAGS) $<
Target for
node_modules
folder.node_modules: package.json
npm install
Clean.
clean: clean-build
.PHONY: clean
Clean generated build.
clean-build:
@rm -rf build
@$(DUO) clean-cache --quiet
.PHONY: clean-build
Clean downloaded dependencies
clean-deps:
@rm -rf node_modules components
@npm cache clean
.PHONY: clean-deps