OSDN Git Service

Regular updates
[twpd/master.git] / make-assets.md
1 ---
2 title: Make for assets
3 layout: 2017/sheet
4 tags: [Archived]
5 archived: This sheet may be listing practices that are outdated.
6 ---
7
8 ### Basic compiling
9
10 ```makefile
11 bin := ./node_modules/.bin
12
13 all: build/foo.js
14
15 build/%.js: src/%.coffee
16     @$(bin)/coffee < $^ > $@
17 ```
18
19 ### Stylus + Autoprefixer
20
21     bin := ./node_modules/.bin
22     stylus := $(bin)/stylus
23     autoprefixer := $(bin)/autoprefixer
24     styl_files := $(shell find web/ -name "*.styl")
25
26     all: public/app.css
27
28     public/app.css: css/app.styl
29
30     %.css: %.styl $(styl_files)
31         @$(stylus) $< | $(autoprefixer) -b "> 1%" > $@
32
33 ### Hint
34
35     hint:
36        $(js_files)
37
38 ### Watching
39
40     watch:
41         @echo "... watching for changes"
42         @while true; do make -s; sleep 1; done
43
44 ### Browserify
45
46     js_files := $(shell find web/ -name "*.js")
47
48     public/app.js: web/app.js
49     public/vendor.js: web/vendor.js
50
51     public/%.js: web/%.js $(js_files)
52         $(browserify) -t [ cssify -x .css ] $< > $@