web3.js/gulpfile.js

66 lines
1.6 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
'use strict';
var path = require('path');
var del = require('del');
var gulp = require('gulp');
var browserify = require('browserify');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var source = require('vinyl-source-stream');
var exorcist = require('exorcist');
var bower = require('bower');
2015-02-17 11:11:57 +00:00
var streamify = require('gulp-streamify');
var DEST = './dist/';
2015-02-17 11:11:57 +00:00
var src = 'index';
var dst = 'ethereum';
var browserifyOptions = {
debug: true,
2015-02-25 14:53:28 +00:00
insert_global_vars: false, // jshint ignore:line
2015-02-17 11:11:57 +00:00
detectGlobals: false,
bundleExternal: false
2014-11-11 09:45:38 +00:00
};
gulp.task('bower', function(cb){
2015-02-17 11:11:57 +00:00
bower.commands.install().on('end', function (installed){
console.log(installed);
cb();
});
2014-11-11 09:45:38 +00:00
});
gulp.task('clean', ['lint'], function(cb) {
2015-02-17 11:11:57 +00:00
del([ DEST ], cb);
});
2014-11-11 09:45:38 +00:00
gulp.task('lint', function(){
2015-02-17 11:11:57 +00:00
return gulp.src(['./*.js', './lib/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
2014-11-11 09:45:38 +00:00
});
gulp.task('build', ['clean'], function () {
2015-02-17 11:11:57 +00:00
return browserify(browserifyOptions)
.require('./' + src + '.js', {expose: 'web3'})
.add('./' + src + '.js')
.bundle()
.pipe(exorcist(path.join( DEST, dst + '.js.map')))
.pipe(source(dst + '.js'))
.pipe(gulp.dest( DEST ))
.pipe(streamify(uglify()))
.pipe(rename(dst + '.min.js'))
.pipe(gulp.dest( DEST ));
});
gulp.task('watch', function() {
2015-02-17 11:11:57 +00:00
gulp.watch(['./lib/*.js'], ['lint', 'build']);
});
2015-02-17 11:11:57 +00:00
gulp.task('dev', ['bower', 'lint', 'build']);
gulp.task('default', ['dev']);