optimize images and add deploy-html target
- resize all images to max 1920px width (152MB → 66MB) - add assets-original/ to gitignore for backups - add make optimize-images target - add make deploy-html for faster HTML-only deployment
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Makefile for Marp Slides Project
|
||||
|
||||
.PHONY: help build dev watch pdf html clean install deploy copy-assets
|
||||
.PHONY: help build dev watch pdf html clean install deploy deploy-html copy-assets optimize-images
|
||||
|
||||
# Directories
|
||||
SLIDES_DIR = slides
|
||||
@@ -27,10 +27,14 @@ help:
|
||||
@echo " make pdf - Export all slides to PDF"
|
||||
@echo " make html - Export all slides to HTML"
|
||||
@echo ""
|
||||
@echo " Deploy:"
|
||||
@echo " make deploy - Full build + deploy (HTML, PDF, assets)"
|
||||
@echo " make deploy-html - HTML only deploy (faster)"
|
||||
@echo ""
|
||||
@echo " Other:"
|
||||
@echo " make optimize-images - Resize images to max 1920px"
|
||||
@echo " make clean - Remove generated files"
|
||||
@echo " make install - Install dependencies"
|
||||
@echo " make deploy - Deploy slides to server"
|
||||
|
||||
# Ensure build directory exists
|
||||
$(BUILD_DIR)/.exists:
|
||||
@@ -91,7 +95,18 @@ install:
|
||||
@echo "Installing dependencies..."
|
||||
npm install
|
||||
|
||||
# Deploy slides
|
||||
# Optimize images (resize to max 1920px, requires nix-shell -p imagemagick)
|
||||
optimize-images:
|
||||
@echo "Backing up originals to assets-original/..."
|
||||
@mkdir -p $(SLIDES_DIR)/assets-original
|
||||
@cp $(SLIDES_DIR)/assets/*.png $(SLIDES_DIR)/assets-original/ 2>/dev/null || true
|
||||
@cp $(SLIDES_DIR)/assets/*.jpg $(SLIDES_DIR)/assets-original/ 2>/dev/null || true
|
||||
@echo "Resizing images to max 1920px..."
|
||||
@nix-shell -p imagemagick --run 'for img in $(SLIDES_DIR)/assets/*.png; do magick "$$img" -resize "1920x>" -quality 85 "$$img"; done'
|
||||
@nix-shell -p imagemagick --run 'for img in $(SLIDES_DIR)/assets/*.jpg; do magick "$$img" -resize "1920x>" -quality 85 "$$img"; done'
|
||||
@echo "Done! Originals backed up in assets-original/"
|
||||
|
||||
# Deploy slides (full build)
|
||||
deploy: build
|
||||
@echo "Deploying slides..."
|
||||
@echo "Copying HTML files..."
|
||||
@@ -100,3 +115,10 @@ deploy: build
|
||||
scp -r $(BUILD_DIR)/assets/ tengo@tuttle.uberspace.de:/home/tengo/html/hdm/223015b/
|
||||
@echo "Copying materials..."
|
||||
scp -r $(BUILD_DIR)/materials/ tengo@tuttle.uberspace.de:/home/tengo/html/hdm/223015b/ 2>/dev/null || true
|
||||
|
||||
# Deploy HTML only (faster, no PDF rebuild)
|
||||
deploy-html: html
|
||||
@echo "Deploying HTML only..."
|
||||
scp $(BUILD_DIR)/*.html tengo@tuttle.uberspace.de:/home/tengo/html/hdm/223015b/
|
||||
scp -r $(BUILD_DIR)/assets/ tengo@tuttle.uberspace.de:/home/tengo/html/hdm/223015b/
|
||||
scp -r $(BUILD_DIR)/materials/ tengo@tuttle.uberspace.de:/home/tengo/html/hdm/223015b/ 2>/dev/null || true
|
||||
|
||||
Reference in New Issue
Block a user