This repository has been archived on 2026-06-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
wiki/moko-platform/MINIFICATION.md
T
2026-05-09 18:32:15 -05:00

2.4 KiB

← Back to Home

Asset Minification

CSS and JS assets are minified at build/release time. Minified files (.min.css, .min.js) ship in release packages but are not committed to git.


Standard

All MokoStandards-compliant repos follow this pattern:

What Where
Source files Committed to git (*.css, *.js)
Minified files Generated at build time, gitignored (*.min.css, *.min.js)
Release ZIPs Include both source and minified versions

Universal Minifier

Location: moko-platform/build/minify.js

Auto-discovers all CSS/JS files in a source directory, skipping vendor/, node_modules/, and already-minified files.

File Type Tool Settings
CSS clean-css Level 1
JS Terser Compress + mangle

Usage

# From any repo root
node path/to/moko-platform/build/minify.js src

# Or via Makefile
make minify

Makefile Integration

Every repo's Makefile includes a minify target:

MOKO_PLATFORM ?= $(or $(wildcard ../moko-platform),$(wildcard $(HOME)/moko-platform),$(wildcard /opt/moko-platform))
MINIFY_SCRIPT := $(MOKO_PLATFORM)/build/minify.js

.PHONY: minify
minify:
    @if [ -f "$(MINIFY_SCRIPT)" ]; then \
        node "$(MINIFY_SCRIPT)" $(SRC_DIR); \
    elif [ -f "scripts/minify.js" ]; then \
        node scripts/minify.js; \
    fi

The build target depends on minify, so make build and make release both minify automatically.


CI/Release Integration

The auto-release.yml workflow includes Step 7.5 (Minify assets) which runs before the ZIP packaging step:

- name: "Step 7.5: Minify assets"
  run: |
    npm install --no-save terser clean-css 2>/dev/null || true
    MINIFY=""
    for p in "../moko-platform/build/minify.js" "scripts/minify.js"; do
      [ -f "$p" ] && MINIFY="$p" && break
    done
    [ -n "$MINIFY" ] && node "$MINIFY" src

This ensures minified assets are in the working tree when the ZIP is built, but never committed.


.gitignore

All repos include:

*.min.css
*.min.js

Repos with Minification Enabled

  • Template-Client-WaaS (client template)
  • Template-Joomla (extension template)
  • Template-MCP (MCP server template)
  • MokoOnyx (Joomla template)
  • client-clarksvillefurs