[Pkg-nagios-changes] [pkg-icingaweb2] 01/01: Add proper Javascript minification with uglifyjs
Markus Frosch
lazyfrosch at moszumanska.debian.org
Mon Aug 8 12:11:00 UTC 2016
This is an automated email from the git hooks/post-receive script.
lazyfrosch pushed a commit to branch master
in repository pkg-icingaweb2.
commit 3f6ff8aefbd76823dd51d9a51a24626f02c4519f
Author: Markus Frosch <lazyfrosch at debian.org>
Date: Mon Aug 8 13:02:59 2016 +0200
Add proper Javascript minification with uglifyjs
---
debian/control | 2 +-
debian/rules | 14 +++-----------
debian/uglify/.gitignore | 3 +++
debian/uglify/Makefile | 41 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 12 deletions(-)
diff --git a/debian/control b/debian/control
index d0966c0..345ea3e 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Build-Depends:
debhelper (>= 9),
php-cli,
php-htmlpurifier (>= 4.3),
- yui-compressor
+ node-uglify | yui-compressor, node-source-map | yui-compressor
Standards-Version: 3.9.8
Homepage: https://www.icinga.org
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-nagios/pkg-icingaweb2.git
diff --git a/debian/rules b/debian/rules
index 3c97cfe..93f6dca 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,11 +6,11 @@
override_dh_auto_clean:
dh_auto_clean
- rm -rf debian/minify
+ cd debian/uglify && $(MAKE) clean
override_dh_install:
dh_install -X.min.js -X.min.map -XSOURCE
- cp -r debian/minify/*.min.js debian/icingaweb2/usr/share/icingaweb2/public/js/vendor/
+ cp -r debian/uglify/*.min.* debian/icingaweb2/usr/share/icingaweb2/public/js/vendor/
override_dh_auto_test:
dh_auto_test
@@ -19,14 +19,6 @@ override_dh_auto_test:
override_dh_auto_build:
dh_auto_build
- mkdir debian/minify
- yui-compressor public/js/vendor/jquery-1.11.0.js \
- > debian/minify/jquery-1.11.0.min.js
- yui-compressor public/js/vendor/jquery-2.1.0.js \
- > debian/minify/jquery-2.1.0.min.js
- yui-compressor public/js/vendor/jquery.sparkline.js \
- > debian/minify/jquery.sparkline.min.js
- yui-compressor public/js/vendor/jquery.tipsy.js \
- > debian/minify/jquery.tipsy.min.js
+ cd debian/uglify && $(MAKE) all
# vi: ts=4 sw=4 noexpandtab :
diff --git a/debian/uglify/.gitignore b/debian/uglify/.gitignore
new file mode 100644
index 0000000..7c1ca85
--- /dev/null
+++ b/debian/uglify/.gitignore
@@ -0,0 +1,3 @@
+*.js
+*.map
+*.head
diff --git a/debian/uglify/Makefile b/debian/uglify/Makefile
new file mode 100644
index 0000000..dc4fa0b
--- /dev/null
+++ b/debian/uglify/Makefile
@@ -0,0 +1,41 @@
+#!/usr/bin/make -f
+# Run uglifyjs to 'compile' the .min.js ourself
+#
+# Fallback to yui-compressor if uglifyjs is not available.
+
+SOURCE_PATH = ../../public/js/vendor
+SOURCES = jquery-1.11.0.js jquery-2.1.0.js jquery.sparkline.js jquery.tipsy.js
+FILES = $(patsubst %.js,%.min.js,$(SOURCES))
+
+UGLIFY_OPTS = -m "toplevel=true" -r '$$,require,exports' -c "hoist_funs=false,loops=false,unused=false"
+
+CAN_UGLIFYJS := $(shell command -v uglifyjs 2>/dev/null)
+
+all: source uglify
+
+clean:
+ rm -f *.js *.map *.head
+
+source: $(SOURCES)
+
+uglify: $(FILES)
+
+%.js:
+ $(eval min := $(patsubst %.js,%.min.js,$@))
+ grep -Pzo '/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/' $(SOURCE_PATH)/$(min) > $@.head
+ cp $(SOURCE_PATH)/$@ .
+
+%.min.js: %.js
+ $(eval map := $(patsubst %.min.js,%.min.map,$@))
+ifdef CAN_UGLIFYJS
+ uglifyjs \
+ $(UGLIFY_OPTS) \
+ -o $@ \
+ --preamble "$$(cat $<.head)" \
+ --source-map $(map) \
+ --source-map-url $(map) -- $<
+ # Add explicit newline (https://dev.icinga.org/issues/12328)
+ echo >> $@
+else
+ yui-compressor $< -o $@
+endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-icingaweb2.git
More information about the Pkg-nagios-changes
mailing list