[!NOTE] 역사적 패턴: Vite, Webpack, esbuild가 표준이 되기 전에는 GNU Make를 프론트엔드 에셋 파이프라인으로 사용하는 것이 일반적이었습니다. 간단한 프로젝트에서는 여전히 가벼운 접근 방식입니다.
기본 컴파일 패턴 (Basic Compilation Pattern)
bin := ./node_modules/.bin
all: build/app.js
build/%.js: src/%.coffee
@mkdir -p $(@D)
@$(bin)/coffee < $< > $@
Stylus 및 Autoprefixer를 활용한 CSS 파이프라인
bin := ./node_modules/.bin
stylus := $(bin)/stylus
autoprefixer := $(bin)/autoprefixer
styl_files := $(shell find web/ -name "*.styl")
all: public/app.css
public/app.css: css/app.styl $(styl_files)
@mkdir -p $(@D)
@$(stylus) $< | $(autoprefixer) -b "> 1%" > $@
파일 감시 루프 (File Watching Loop)
파일 변경 시 make 타깃을 다시 실행하기 위한 간단한 셸 루프:
watch:
@echo "... watching for file changes"
@while true; do make -s; sleep 1; done
Browserify를 사용한 JavaScript 번들링
js_files := $(shell find web/ -name "*.js")
public/app.js: web/app.js $(js_files)
@mkdir -p $(@D)
@$(browserify) -t [ cssify -x .css ] $< > $@