diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-11-21 18:30:14 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-11-22 12:49:14 +0100 |
commit | 17690f2d73b640cf4bbf082fe96f5b3075a040fe (patch) | |
tree | 0a2c56e6bb6298c4e69046d6c3c44bdf086325b5 /luci.mk | |
parent | 9b7f606dc66d58f0e1f21d20e191498375da746f (diff) |
build: add build option to minify *.js files
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'luci.mk')
-rw-r--r-- | luci.mk | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -84,7 +84,7 @@ PKG_GITBRANCH?=$(if $(DUMP),x,$(strip $(shell \ PKG_RELEASE?=1 PKG_INSTALL:=$(if $(realpath src/Makefile),1) PKG_BUILD_DEPENDS += lua/host luci-base/host $(LUCI_BUILD_DEPENDS) -PKG_CONFIG_DEPENDS += CONFIG_LUCI_SRCDIET +PKG_CONFIG_DEPENDS += CONFIG_LUCI_SRCDIET CONFIG_LUCI_JSMIN PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) @@ -113,6 +113,10 @@ ifeq ($(PKG_NAME),luci-base) bool "Minify Lua sources" default n + config LUCI_JSMIN + bool "Minify JavaScript sources" + default y + menu "Translations"$(foreach lang,$(LUCI_LANGUAGES), config LUCI_LANG_$(lang) @@ -158,6 +162,13 @@ define SrcDiet done endef +define JsMin + $(FIND) $(1) -type f -name '*.js' | while read src; do \ + if jsmin < "$$$$src" > "$$$$src.o"; \ + then mv "$$$$src.o" "$$$$src"; fi; \ + done +endef + define SubstituteVersion $(FIND) $(1) -type f -name '*.htm' | while read src; do \ $(SED) 's/<%# *\([^ ]*\)PKG_VERSION *%>/\1$(PKG_VERSION)/g' \ @@ -177,6 +188,7 @@ define Package/$(PKG_NAME)/install if [ -d $(PKG_BUILD_DIR)/htdocs ]; then \ $(INSTALL_DIR) $(1)$(HTDOCS); \ cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/; \ + $(if $(CONFIG_LUCI_JSMIN),$(call JsMin,$(1)$(HTDOCS)/),true); \ else true; fi if [ -d $(PKG_BUILD_DIR)/root ]; then \ $(INSTALL_DIR) $(1)/; \ |