[Makefile] Concetenate and Minify CSS via sed and tr Command

Concatenate and Minify CSS via sed and tr command in Makefile.

SOURCE_CSS_FILES=$(filter-out %.min.css, $(wildcard *.css))

minify: concat
      @# remove css comments
      sed -r ':a; s%(.*)/\*.*\*/%\1%; ta; /\/\*/ !b; N; ba' -i $(MINIFIED_CSS)
      @# remove leading spaces and tabs
      sed 's/^\s*//' -i $(MINIFIED_CSS)
      @# remove trailing spaces, tabs, and newline
      sed 's/\s*$$//' -i $(MINIFIED_CSS)
      @# remove newline
      tr --delete '\n' < $(MINIFIED_CSS) > tmp.css
      mv tmp.css $(MINIFIED_CSS)


Tested on Ubuntu Linux 15.10.


[1]GNU make: Text Functions
[2]GNU make: Wildcard Function

sed remove comments c

sed - Remove multi-line comments - Stack Overflow

[4]unix - how to remove leading whitespace from each line in a file? - Stack Overflow
[5]bash - How to use sed in a Makefile - Stack Overflow
[6]unix - How can I replace a newline (n) using sed? - Stack Overflow

makefile instead of grunt

What's in a Build Tool? (lihaoyi.com) (HN discussions)

ocaml-9p/Makefile at master · mirage/ocaml-9p · GitHub

rappel/Makefile at master · yrp604/rappel · GitHub

In defense of Unix (leancrew.com) (HN discussions)

[8]makefile check if symlink exists

makefile concatenate files

javascript - Makefile to combine js files and make a compressed version - Stack Overflow

build - Is there a way to exclude certain source files or folders from a makefile? - Stack Overflow

[10]concatenate and minify css via make/sed/tr · siongui/pali@188d66f · GitHub
[11]tr replace file