Skip to content

Instantly share code, notes, and snippets.

@poying
Last active August 29, 2015 14:10
Show Gist options
  • Save poying/7234dd58eb2c9baadbc8 to your computer and use it in GitHub Desktop.
Save poying/7234dd58eb2c9baadbc8 to your computer and use it in GitHub Desktop.
# 本地執行檔放置的目錄
NW = ./node_modules/.bin
DUO = $(NW)/duo
# 取得所有 js、html 檔案路徑
# 因為 duo 會把 html 轉成 js 字串,所以除了間看 js 外也要監看 html
JS_FILES = $(shell find lib -name "*.js" -o -name "*.html")
# 取得所有 css 還有使用到的檔案路徑,像是圖片
CSS_FILES = $(shell find lib -name "*.css" -o -name "*.png" -o -name "*.svg")
# build 目錄位置
DIST = ./build
all: $(DIST)/build.js $(DIST)/build.css
# 如果 js、html 檔案沒有更動過,make 就不會執行這個 rule
$(DIST)/build.js: $(DIST) $(JS_FILES)
# 顯示時間,方便知道他有沒有執行
@date
# 將 duo build 的結果存到 build/build.js 裡
@$(DUO) --development ./lib/index.js > $@
# 同理,如果 css、圖片檔案沒有更動過,make 就不會執行這個 rule
$(DIST)/build.css: $(DIST) $(CSS_FILES)
@date
@$(DUO) --development ./lib/index.css > $@
# 建立 build 目錄
$(DIST):
@-mkdir -p $@
clean:
@-rm -rf $(DIST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment