Skip to content

Instantly share code, notes, and snippets.

@sperand-io
Last active August 29, 2015 14:20
Show Gist options
  • Save sperand-io/f00005c0bfc00bfd32a0 to your computer and use it in GitHub Desktop.
Save sperand-io/f00005c0bfc00bfd32a0 to your computer and use it in GitHub Desktop.
Example Duo Makefile
#
# Environment.
#
NODE := node --harmony
NODE_ENV ?= development
#
# Binaries
#
BIN := ./node_modules/.bin
DUO := $(BIN)/duo
#
# Command Flags
#
DUO_FLAGS := --quiet --copy --use ./lib/duo/plugins
ifeq ($(NODE_ENV),development)
DUO_FLAGS += --development
else
DUO_FLAGS += --external-source-maps
endif
#
# Wildcards.
#
JS := $(wildcard client/*/index.js)
JS += $(shell find apps -path '*/client/index.js')
CSS := $(shell find apps -path '*/client/index.css')
PUBLIC := $(shell find apps -name public -type d)
#
# Build.
#
build: node_modules $(addprefix build/, $(JS) $(CSS) $(PUBLIC))
.PHONY: 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 public dirs
#
build/%/public: %/public
@$(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
var babel = require('duo-babel');
var myth = require('duo-myth');
var plugins = [
babel({ jsxPragma: 'element' }), // https://github.com/segmentio/deku/blob/master/docs/guides/jsx.md
myth() // myth.io
];
if (process.env.NODE_ENV === 'production') {
var uglify = require('duo-uglify');
plugins.push(uglify());
}
module.exports = plugins;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment