-
-
Save tomelam/f263bb3fcf839d88596f6c2017f81e3a to your computer and use it in GitHub Desktop.
Minimalist makefile using PostCSS
This file contains 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
# some variables | |
POSTCSS = ./node_modules/.bin/postcss | |
POSTCSS_FLAGS = --use autoprefixer autoprefixer.browsers "> 2%" | |
# wildcard expansion is performed only in targets and in prerequisites so here we need $(wildcard) | |
SOURCES = $(wildcard src/css/*.css) | |
# use $(SOURCES) to determine what we actually need using a bit of pattern substitution | |
TARGETS = $(patsubst src%, build%, $(SOURCES)) | |
# our default target (see below) | |
all: $(TARGETS) | |
# as described halfway through https://www.thumbtack.com/engineering/makefiles-for-less-and-css/ | |
# current make needs an explicit target such as "all" when there is only one build target | |
build/css/%.css: src/css/%.css | |
@echo "$< => $@" | |
@$(POSTCSS) $(POSTCSS_FLAGS) --output $@ $< | |
# simply removes $(TARGETS) | |
clean: | |
-@rm -f $(TARGETS) | |
# both all and clean are not actual filenames | |
.PHONY: all clean |
This file contains 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
{ | |
"devDependencies": { | |
"autoprefixer": "^6.3.1", | |
"postcss-cli": "^2.5.0", | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment