-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement minification in in the makefile (#67)
* Implement minification in makefilec Signed-off-by: Mateus Felipe C. C. Pinto <mateusfccp@gmail.com> * Improve minify command by passing minify as entrypoint Signed-off-by: Mateus Felipe C. C. Pinto <mateusfccp@gmail.com> --------- Signed-off-by: Mateus Felipe C. C. Pinto <mateusfccp@gmail.com>
- Loading branch information
1 parent
aa5f5db
commit b4d4d35
Showing
3 changed files
with
37 additions
and
35 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,48 @@ | ||
EMACS_INIT := /root/.emacs.d/init.el | ||
EMACS_LOAD := -l $(EMACS_INIT) | ||
EMACS_FLAGS := --batch --kill $(EMACS_LOAD) | ||
ORG_FILES := $(wildcard *.org) | ||
HTML_FILES := $(patsubst %.org, %.html, $(ORG_FILES)) | ||
DOCKER_IMG := commonlispbr/emacs | ||
USER := $(shell id -u):$(shell id -g) | ||
DOCKER_RUN := docker run -w /tmp \ | ||
-v $(shell pwd):/tmp \ | ||
--rm \ | ||
-t | ||
STATUS_PREFIX := "\033[1;32m[+]\033[0m " | ||
ATTENTION_PREFIX := "\033[1;36m[!]\033[0m " | ||
EMACS_INIT := /root/.emacs.d/init.el | ||
EMACS_LOAD := -l $(EMACS_INIT) | ||
EMACS_FLAGS := --batch --kill $(EMACS_LOAD) | ||
ORG_FILES := $(wildcard *.org) | ||
HTML_FILES := $(patsubst %.org, %.html, $(ORG_FILES)) | ||
STATIC_FILES_FOLDER := static/ | ||
DOCKER_IMG := commonlispbr/emacs | ||
MINIFY_IMG := tdewolff/minify | ||
USER := $(shell id -u):$(shell id -g) | ||
DOCKER_RUN := docker run -w /tmp \ | ||
-v $(shell pwd):/tmp \ | ||
--rm \ | ||
-t | ||
MINIFY := $(DOCKER_RUN) --entrypoint="/usr/bin/minify" $(MINIFY_IMG) | ||
|
||
STATUS_PREFIX := "\033[1;32m[+]\033[0m " | ||
|
||
.PHONY: clean shell | ||
|
||
all: $(HTML_FILES) copy | ||
all: setup $(HTML_FILES) minify | ||
|
||
shell: | ||
$(DOCKER_RUN) -i --entrypoint=/bin/zsh $(DOCKER_IMG) | ||
|
||
setup: | ||
@printf $(STATUS_PREFIX); echo "CREATING STATIC FOLDER: $(STATIC_FILES_FOLDER)" | ||
@mkdir -p static | ||
|
||
%.html: %.org | ||
@printf $(STATUS_PREFIX); echo "COMPILING: $< -> $*.html" | ||
@$(DOCKER_RUN) $(DOCKER_IMG) $< $(EMACS_FLAGS) -f org-html-export-to-html | ||
@$(DOCKER_RUN) --entrypoint=/bin/chown $(DOCKER_IMG) $(USER) "$*.html" | ||
@mv $*.html $(STATIC_FILES_FOLDER)/$*.html | ||
@printf $(STATUS_PREFIX); echo "MINIFYING: $*.html" | ||
@$(MINIFY) $(STATIC_FILES_FOLDER)/$*.html -o $(STATIC_FILES_FOLDER)/$*.html | ||
|
||
copy: | ||
@mkdir -p static | ||
@find . \ | ||
"(" -name "*.html" -o -name "*.css" -o -name "*.js" ")" \ | ||
-not -path "./static/*" \ | ||
-not -path "./.github/*" \ | ||
-exec cp {} static \; | ||
@find . \ | ||
-name "*.html" \ | ||
-not -path "./static/*" \ | ||
-not -path "./.github/*" \ | ||
-exec mv {} static \; | ||
minify: | ||
@printf $(STATUS_PREFIX); echo "MINIFYING AND BUNDLING CSS FILES" | ||
@$(MINIFY) --bundle org-theme/dist/long/bundle.css css/syntax.css -o $(STATIC_FILES_FOLDER)/long.css | ||
@$(MINIFY) --bundle org-theme/dist/short/bundle.css css/syntax.css -o $(STATIC_FILES_FOLDER)/short.css | ||
@printf $(STATUS_PREFIX); echo "MINIFYING JS FILES" | ||
@$(MINIFY) --bundle org-theme/dist/long/bundle.js -o $(STATIC_FILES_FOLDER)/long.js | ||
@$(MINIFY) --bundle org-theme/dist/long/bundle.js -o $(STATIC_FILES_FOLDER)/short.js | ||
|
||
server: | ||
python3 -m http.server 8000 --directory ./static | ||
python3 -m http.server 8000 --directory $(STATIC_FILES_FOLDER) | ||
|
||
clean: | ||
rm -rf ./static | ||
rm -rf $(STATIC_FILES_FOLDER) |
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
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