[Libreoffice-commits] online.git: loleaflet/build loleaflet/Jakefile.js loleaflet/Makefile

Pranav Kant pranavk at collabora.co.uk
Tue Aug 16 05:43:05 UTC 2016


 loleaflet/Jakefile.js    |    9 ++++++---
 loleaflet/Makefile       |   15 ++++-----------
 loleaflet/build/build.js |   21 ++++++++++++---------
 3 files changed, 22 insertions(+), 23 deletions(-)

New commits:
commit e86e7a73f847c5bfbeda347c25981418903e1662
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Aug 16 11:07:55 2016 +0530

    loleaflet: performance improvements in build process
    
    Minifiying the js code was taking too much time. Minifying is not
    really needed on developer's machine, so lets disable it by
    default, otherwise it gets annoying during development having to
    wait for so many seconds for it to build.
    
    A simple 'make' now means no debug-info and non-minified
    bundle.js. To add debug-info(source-maps), do 'make DEBUG=true'.
    And to minify, similarly use the MINIFY=true variable with make.
    
    'make dist' forcefully minifies the js code.

diff --git a/loleaflet/Jakefile.js b/loleaflet/Jakefile.js
index 81a0093..8d60824 100644
--- a/loleaflet/Jakefile.js
+++ b/loleaflet/Jakefile.js
@@ -47,11 +47,14 @@ task('build', {async: true}, function (compsBase32, buildName) {
 });
 
 desc('Browserify and bundle all js and css files');
-task('bundle', {async: true}, function (type, debug) {
+task('bundle', {async: true}, function (type, debug, minify) {
+	debug = debug === 'true';
+	minify = minify === 'true';
+
 	if (type === 'admin') {
-		build.bundleAdmin(debug);
+		build.bundleAdmin(debug, minify);
 	} else {
-		build.bundle(debug);
+		build.bundle(debug, minify);
 	}
 });
 
diff --git a/loleaflet/Makefile b/loleaflet/Makefile
index d988a79..e6fc663 100644
--- a/loleaflet/Makefile
+++ b/loleaflet/Makefile
@@ -9,6 +9,7 @@ VERSION=1.9.0
 DRAW_VERSION=0.2.4
 
 DEBUG=false
+MINIFY=false
 
 .PHONY: build
 build:
@@ -17,21 +18,13 @@ build:
 	jake build
 	rm -rf dist/plugins/draw-$(DRAW_VERSION) && mkdir -p dist/plugins/draw-$(DRAW_VERSION)
 	cd plugins/draw-$(DRAW_VERSION) && jake build && cp -ar dist ../../dist/plugins/draw-$(DRAW_VERSION)
-	if $(DEBUG); then \
-		jake bundle[,true]; \
-		jake bundle[admin,true]; \
-	else \
-		jake bundle; \
-		jake bundle[admin]; \
-	fi;
+	jake bundle[,$(DEBUG),$(MINIFY)]
+	jake bundle[admin,$(DEBUG),$(MINIFY)]
 
 all: build
 
-.PHONY: debug
-debug: DEBUG=true
-debug: build
-
 .PHONY: dist
+dist: MINIFY=true
 dist: all
 	rm -rf loleaflet-$(VERSION)
 	mkdir loleaflet-$(VERSION)
diff --git a/loleaflet/build/build.js b/loleaflet/build/build.js
index 5f8a89c..f43c2c8 100644
--- a/loleaflet/build/build.js
+++ b/loleaflet/build/build.js
@@ -97,12 +97,15 @@ function bytesToKB(bytes) {
     return (bytes / 1024).toFixed(2) + ' KB';
 }
 
-function bundle(files, destFilename, debug) {
+function bundle(files, destFilename, debug, minify) {
 	var bundler = browserify(files, {debug: debug});
-	bundler.transform(browserifyCss)
-		   .transform({
-			   global: true
-		   }, 'uglifyify');
+	bundler = bundler.transform(browserifyCss);
+	if (minify) {
+		console.log('uglifying');
+		bundler.transform({
+			global: true
+		}, 'uglifyify');
+	}
 	var bundleFs = fs.createWriteStream('dist/' + destFilename);
 	var res = bundler.bundle();
 	if (debug) {
@@ -115,12 +118,12 @@ function bundle(files, destFilename, debug) {
 	});
 };
 
-exports.bundle = function(debug) {
-	bundle(['main.js'], 'bundle.js', debug);
+exports.bundle = function(debug, minify) {
+	bundle(['main.js'], 'bundle.js', debug, minify);
 };
 
-exports.bundleAdmin = function(debug) {
-	bundle(['main-admin.js'], 'admin-bundle.js', debug);
+exports.bundleAdmin = function(debug, minify) {
+	bundle(['main-admin.js'], 'admin-bundle.js', debug, minify);
 };
 
 exports.build = function (callback, version, compsBase32, buildName) {


More information about the Libreoffice-commits mailing list