Skip to content

Instantly share code, notes, and snippets.

@Doridian
Created January 6, 2025 04:04
Show Gist options
  • Select an option

  • Save Doridian/a96e7c2a82cb1278b6f0c1879c298476 to your computer and use it in GitHub Desktop.

Select an option

Save Doridian/a96e7c2a82cb1278b6f0c1879c298476 to your computer and use it in GitHub Desktop.
hackmud uglify
SRCS=$(wildcard scripts_raw/*.js)
OBJS=$(SRCS:scripts_raw/%.js=scripts/%.js)
scripts/%.js: scripts_raw/%.js
echo '"use strict";module.exports=' > $@.tmp.js
sed 's/#/__HASHTAG__/g' < $< >> $@.tmp.js
uglifyjs -m -c < $@.tmp.js | \
sed 's/__HASHTAG__/#/g' | \
sed 's/^"use strict";module.exports=//' | \
sed 's/^module.exports=//' | \
sed 's/\.prototype/["prototype"]/g' | \
sed 's/\.__proto__/["__proto__"]/g' | \
sed 's/;$$//' > $@
rm -f $@.tmp.js
all: $(OBJS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment