
This adds karma-chrome-launcher and uses it instead of phantomjs for running all unit tests. Currently, the 'phantomjs-prebuilt' package downloads binaries from bitbucket, and gate job have been failing due to rate limiting from their servers. Since Chrome is already being installed from local mirrors as part of the 'npm run' job template, this should avoid further problems. Additionally, this bumps all npm dependencies to their latest versions and removes several (such as babel) that are unused. Some minor tweaks to gulp tasks were needed to account for changes, but these are fairly minimal. Change-Id: Ia003280ab30f2912935140ecd4734ae8a08dd44d
72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
var config = require('../config');
|
|
var gulp = require('gulp');
|
|
var gulpif = require('gulp-if');
|
|
var gutil = require('gulp-util');
|
|
var source = require('vinyl-source-stream');
|
|
var sourcemaps = require('gulp-sourcemaps');
|
|
var buffer = require('vinyl-buffer');
|
|
var streamify = require('gulp-streamify');
|
|
var watchify = require('watchify');
|
|
var browserify = require('browserify');
|
|
var uglify = require('gulp-uglify');
|
|
var handleErrors = require('../util/handleErrors');
|
|
var browserSync = require('browser-sync');
|
|
var ngAnnotate = require('browserify-ngannotate');
|
|
|
|
// Based on: http://blog.avisi.nl/2014/04/25/how-to-keep-a-fast-build-with-browserify-and-reactjs/
|
|
function buildScript(file) {
|
|
|
|
var bundler = browserify({
|
|
entries: config.browserify.entries,
|
|
debug: true,
|
|
cache: {},
|
|
packageCache: {},
|
|
fullPaths: true
|
|
}, watchify.args);
|
|
|
|
if ( !global.isProd ) {
|
|
bundler = watchify(bundler);
|
|
bundler.on('update', function() {
|
|
rebundle();
|
|
});
|
|
}
|
|
|
|
var transforms = [
|
|
ngAnnotate,
|
|
'bulkify'
|
|
];
|
|
|
|
transforms.forEach(function(transform) {
|
|
bundler.transform(transform);
|
|
});
|
|
|
|
function rebundle() {
|
|
var stream = bundler.bundle();
|
|
var createSourcemap = config.browserify.sourcemap;
|
|
|
|
gutil.log('Rebundle...');
|
|
|
|
return stream.on('error', handleErrors)
|
|
.pipe(source(file))
|
|
.pipe(gulpif(createSourcemap, buffer()))
|
|
.pipe(gulpif(createSourcemap, sourcemaps.init({ loadMaps: true })))
|
|
.pipe(gulpif(global.isProd, streamify(uglify({
|
|
compress: { drop_console: true }
|
|
}))))
|
|
.pipe(gulpif(createSourcemap, sourcemaps.write('./')))
|
|
.pipe(gulp.dest(config.scripts.dest))
|
|
.pipe(browserSync.reload({ stream: true, once: true }));
|
|
}
|
|
|
|
return rebundle();
|
|
|
|
}
|
|
|
|
gulp.task('browserify', function() {
|
|
|
|
return buildScript('main.js');
|
|
|
|
});
|