Skip to content

Commit

Permalink
fix(build): build minifies using uglifyjs
Browse files Browse the repository at this point in the history
This commit fixes a bug in which ECMAScript 6 features were used in the
client, breaking `uglify`'s build.  These features have been removed in
favor of their ES5 alternates.

The `pump` module has been added as a development dependency due to
better gulp build errors.

Closes #704.
  • Loading branch information
Jonathan Niles committed Sep 9, 2016
1 parent 971d46f commit 3d40738
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/src/js/services/PatientInvoiceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function PatientInvoiceService(Modal, util, Session, Api) {

// returns columns from filters
return columns.filter(function (column) {
let value = params[column.field];
var value = params[column.field];

if (angular.isDefined(value)) {
column.value = value;
Expand Down
4 changes: 2 additions & 2 deletions client/src/js/services/PatientService.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function PatientService($http, util, Session, $uibModal, Documents, Visits) {
// document exposition definition
service.Documents = Documents;
service.Visits = Visits;
service.latest = latest;
service.latest = latest;

/**
* This method returns information on a patient given the patients UUID. This
Expand Down Expand Up @@ -223,7 +223,7 @@ function PatientService($http, util, Session, $uibModal, Documents, Visits) {

// returns columns from filters
return columns.filter(function (column) {
let value = params[column.field];
var value = params[column.field];

if (angular.isDefined(value)) {
column.value = value;
Expand Down
18 changes: 11 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const cssnano = require('gulp-cssnano');
const iife = require('gulp-iife');
const pump = require('pump');
const rimraf = require('rimraf');
const less = require('gulp-less');

// child process for custom scripts
const exec = require('child_process').exec;

// toggle client javascript minification
const UGLIFY = false;
const UGLIFY = (process.env.NODE_ENV === 'production');

// the output folder for built server files
const SERVER_FOLDER = './bin/server/';
Expand Down Expand Up @@ -128,12 +129,15 @@ const paths = {


// minify the client javascript code via uglify writes output to bhima.min.js
gulp.task('client-compile-js', function () {
return gulp.src(paths.client.javascript)
.pipe(gulpif(UGLIFY, uglify({ mangle: true })))
.pipe(concat('js/bhima.min.js'))
.pipe(iife())
.pipe(gulp.dest(CLIENT_FOLDER));
gulp.task('client-compile-js', function (cb) {
pump([
gulp.src(paths.client.javascript),
gulpif(UGLIFY, uglify({ mangle: true })),
concat('js/bhima.min.js'),
iife(),
gulp.dest(CLIENT_FOLDER)
], cb);

});

// minify the vendor JS code and compact into a vendor.min.js file.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"mocha": "^3.0.0",
"mochawesome-screenshots": "^1.4.1",
"protractor": "^4.0.2",
"pump": "^1.0.1",
"rimraf": "^2.5.4"
},
"homepage": "https://github.com/IMA-WorldHealth/bhima-2.X#readme",
Expand Down

0 comments on commit 3d40738

Please sign in to comment.