With updated deps
This commit is contained in:
69
utils/browserify.js
Executable file
69
utils/browserify.js
Executable file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
Use Browserify to bundle up our tests.
|
||||
|
||||
gulp test --watch --tests './tests/checkboxWithLabel-test.js'
|
||||
|
||||
Thanks to - http://blog.avisi.nl/2014/04/25/how-to-keep-a-fast-build-with-browserify-and-reactjs/
|
||||
*/
|
||||
|
||||
var gulp = require('gulp');
|
||||
var source = require('vinyl-source-stream');
|
||||
var browserify = require('browserify');
|
||||
var watchify = require('watchify');
|
||||
var reactify = require('reactify');
|
||||
var livereload = require('gulp-livereload');
|
||||
var gulpif = require('gulp-if');
|
||||
var path = require('path');
|
||||
var uglify = require('gulp-uglify');
|
||||
var streamify = require('gulp-streamify');
|
||||
var notify = require('gulp-notify');
|
||||
|
||||
var handleError = require('./handleError');
|
||||
|
||||
var getTimeStamp = function () {
|
||||
var date = new Date();
|
||||
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
|
||||
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
|
||||
return hours + ':' + minutes;
|
||||
};
|
||||
|
||||
var runBrowserify = function (options) {
|
||||
|
||||
var bundler = browserify({
|
||||
entries: [options.src],
|
||||
transform: [reactify],
|
||||
debug: true,
|
||||
standalone: 'ReactDispatcher',
|
||||
cache: {}, packageCache: {}, fullPaths: true
|
||||
});
|
||||
var rebundle = function() {
|
||||
console.log('[' + getTimeStamp() + '] Building');
|
||||
var start = Date.now();
|
||||
var fileName = options.uglify ? 'ReactDispatcher.min.js' : path.basename(options.src);
|
||||
bundler.bundle()
|
||||
.on('error', handleError('Browserify'))
|
||||
.pipe(source(options.isTest ? 'test.js' : fileName))
|
||||
.pipe(gulpif(options.uglify, streamify(uglify())))
|
||||
.pipe(gulp.dest(options.dest))
|
||||
.pipe(gulpif(options.isTest, livereload()))
|
||||
.pipe(notify(function () {
|
||||
console.log('[' + getTimeStamp() + '] Built in ' + (Date.now() - start) + 'ms');
|
||||
}));
|
||||
};
|
||||
|
||||
if (options.isTest) {
|
||||
livereload.listen();
|
||||
}
|
||||
|
||||
if (options.watch) {
|
||||
bundler = watchify(bundler);
|
||||
bundler.on('update', rebundle);
|
||||
}
|
||||
|
||||
bundler.transform(reactify);
|
||||
|
||||
return rebundle();
|
||||
|
||||
};
|
||||
|
||||
module.exports = runBrowserify;
|
||||
24
utils/css.js
Normal file
24
utils/css.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var gulp = require('gulp');
|
||||
var concat = require('gulp-concat');
|
||||
var cssmin = require('gulp-cssmin');
|
||||
|
||||
var handleError = require('./handleError');
|
||||
|
||||
var runCss = function (options) {
|
||||
|
||||
if (options.watch) {
|
||||
return gulp.watch(options.src, function () {
|
||||
return gulp.src(options.src)
|
||||
.pipe(concat('main.css'))
|
||||
.pipe(gulp.dest(options.dest));
|
||||
});
|
||||
} else {
|
||||
return gulp.src(options.src)
|
||||
.pipe(concat('main.css'))
|
||||
.pipe(cssmin())
|
||||
.pipe(gulp.dest(options.dest));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = runCss;
|
||||
1431
utils/es5-shim.js
Executable file
1431
utils/es5-shim.js
Executable file
File diff suppressed because it is too large
Load Diff
12
utils/handleError.js
Executable file
12
utils/handleError.js
Executable file
@@ -0,0 +1,12 @@
|
||||
var gutil = require('gulp-util');
|
||||
var notify = require('gulp-notify');
|
||||
|
||||
module.exports = function (task) {
|
||||
return function(err) {
|
||||
gutil.log(gutil.colors.red(err));
|
||||
notify.onError(task + ' failed, check the logs..')(err);
|
||||
|
||||
// Keep gulp or browserify from hanging on this task
|
||||
this.emit('end');
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user