Skip to content

Instantly share code, notes, and snippets.

@ikedas
Created July 18, 2018 12:58
Show Gist options
  • Save ikedas/7729dbb8e14a6fe714469c8c9925c873 to your computer and use it in GitHub Desktop.
Save ikedas/7729dbb8e14a6fe714469c8c9925c873 to your computer and use it in GitHub Desktop.
Poorman's js minifier
diff --git a/default/web_tt2/head_javascript.tt2 b/default/web_tt2/head_javascript.tt2
index 239eb73..3bf0d72 100644
--- a/default/web_tt2/head_javascript.tt2
+++ b/default/web_tt2/head_javascript.tt2
@@ -41,7 +41,7 @@ var lang = '[% lang %]';
 [%# Color picker ~%]
 <script src="[% static_content_url %]/js/jquery-minicolors/jquery.minicolors.min.js?v2.3.1"></script>
 [%# Sympa ~%]
-<script src="[% static_content_url %]/js/sympa.js?v[% version %]"></script>
+<script src="[% static_content_url %]/js/sympa.min.js?v[% version %]"></script>

 [%# Foundation and other ui adaptation ~%]
 <!--[if lt IE 9]>
diff --git a/www/Makefile.am b/www/Makefile.am
index 1dec9db..7526332 100644
--- a/www/Makefile.am
+++ b/www/Makefile.am
@@ -366,9 +366,19 @@ nobase_static_DATA = \
        js/jquery-ui/jquery-ui.js \
        js/respondjs/respond.min.js \
        js/sympa.js
+nobase_nodist_static_DATA = \
+       js/sympa.min.js

 EXTRA_DIST = $(nobase_static_DATA)

+CLEANFILES = js/sympa.min.js
+
+js/sympa.min.js: js/sympa.js Makefile
+       @rm -f $@
+       $(AM_V_GEN)$(PERL) -0pe \
+       's{(?<!:)//.*\n}{/* */}g;s{/[*].*?[*]/}{ }gs;s{\s+}{ }g' \
+       js/sympa.js > $@
+
 install-data-hook:
        @echo "Creating static_content directory"
        -@for dir in $(staticdir); do \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment