From 4be4db5e6cfdde4ba5c1243b2bafeb6bbae3643c Mon Sep 17 00:00:00 2001 From: Marian Oancea Date: Wed, 5 Nov 2014 19:46:01 +0200 Subject: Converted to node module Converted to npm package Added brower Added browserify with minification Updated Readme --- gulpfile.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 gulpfile.js (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 000000000..de893a4f5 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,56 @@ +#!/usr/bin/env node + +'use strict'; + +var del = require('del'); +var gulp = require('gulp'); +var browserify = require('gulp-browserify-thin'); +var jshint = require('gulp-jshint'); +var uglify = require("gulp-uglify"); +var rename = require("gulp-rename"); +var bower = require('bower'); + +var DEST = './dist/'; + +gulp.task('bower', function(cb){ + bower.commands.install().on('end', function (installed){ + console.log(installed); + cb(); + }); +}); + +gulp.task('lint', function(){ + return gulp.src(['./*.js', './lib/*.js']) + .pipe(jshint()) + .pipe(jshint.reporter('default')); +}); + +gulp.task('clean', ['lint'], function(cb) { + del([ DEST ], cb); +}); + +gulp.task('build', ['clean'], function () { + return browserify() + .require('./index.js', { expose: 'web3'}) + .bundle('ethereum.js') + .on('error', function(err) + { + console.error(err.toString()); + process.exit(1); + }) + .pipe(gulp.dest( DEST )); +}); + +gulp.task('minify', ['build'], function(){ + return gulp.src( DEST + 'ethereum.js') + .pipe(gulp.dest( DEST )) + .pipe(uglify()) + .pipe(rename('ethereum.min.js')) + .pipe(gulp.dest( DEST )); +}); + +gulp.task('watch', function() { + gulp.watch(['./lib/*.js'], ['lint', 'build', 'minify']); +}); + +gulp.task('default', ['bower', 'lint', 'build', 'minify']); -- cgit v1.2.3 From 3270b432bcb007944e3b6e17329b062cb6b7da78 Mon Sep 17 00:00:00 2001 From: Marian Oancea Date: Thu, 6 Nov 2014 22:51:37 +0200 Subject: Refactoring Removed browser fixes Updated gulp to bypass native browser objects Added source map for dist --- gulpfile.js | 54 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index de893a4f5..120e4532d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,14 +2,21 @@ 'use strict'; +var path = require('path'); + var del = require('del'); var gulp = require('gulp'); -var browserify = require('gulp-browserify-thin'); +var browserify = require('browserify'); var jshint = require('gulp-jshint'); -var uglify = require("gulp-uglify"); -var rename = require("gulp-rename"); +var uglify = require('gulp-uglify'); +var rename = require('gulp-rename'); +var envify = require('envify/custom'); +var unreach = require('unreachable-branch-transform'); +var source = require('vinyl-source-stream'); +var exorcist = require('exorcist'); var bower = require('bower'); + var DEST = './dist/'; gulp.task('bower', function(cb){ @@ -30,27 +37,46 @@ gulp.task('clean', ['lint'], function(cb) { }); gulp.task('build', ['clean'], function () { - return browserify() - .require('./index.js', { expose: 'web3'}) - .bundle('ethereum.js') - .on('error', function(err) - { - console.error(err.toString()); - process.exit(1); + return browserify({ + debug: true, + insert_global_vars: false, + detectGlobals: false, + bundleExternal: false + }) + .add('./') + .require('./index.js', {expose: 'web3'}) + .transform('envify', { + NODE_ENV: 'build' + }) + .transform('unreachable-branch-transform') + .transform('uglifyify', { + mangle: false, + compress: { + dead_code: false, + conditionals: true, + unused: false, + hoist_funs: true, + hoist_vars: true, + negate_iife: false + }, + beautify: false, + warnings: true, }) + .bundle() + .pipe(exorcist(path.join( DEST, 'ethereum.js.map'))) + .pipe(source('ethereum.js')) .pipe(gulp.dest( DEST )); }); -gulp.task('minify', ['build'], function(){ +gulp.task('uglify', ['build'], function(){ return gulp.src( DEST + 'ethereum.js') - .pipe(gulp.dest( DEST )) .pipe(uglify()) .pipe(rename('ethereum.min.js')) .pipe(gulp.dest( DEST )); }); gulp.task('watch', function() { - gulp.watch(['./lib/*.js'], ['lint', 'build', 'minify']); + gulp.watch(['./lib/*.js'], ['lint', 'build', 'uglify']); }); -gulp.task('default', ['bower', 'lint', 'build', 'minify']); +gulp.task('default', ['bower', 'lint', 'build', 'uglify']); -- cgit v1.2.3 From d95e2b7999750a8a2fb3c54258935f916379e6c6 Mon Sep 17 00:00:00 2001 From: Marian Oancea Date: Mon, 10 Nov 2014 14:53:35 +0200 Subject: Fixed jshint warnings --- gulpfile.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 120e4532d..987c127ba 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -36,7 +36,7 @@ gulp.task('clean', ['lint'], function(cb) { del([ DEST ], cb); }); -gulp.task('build', ['clean'], function () { +gulp.task('prepare', ['clean'], function () { return browserify({ debug: true, insert_global_vars: false, @@ -59,8 +59,8 @@ gulp.task('build', ['clean'], function () { hoist_vars: true, negate_iife: false }, - beautify: false, - warnings: true, + beautify: true, + warnings: true }) .bundle() .pipe(exorcist(path.join( DEST, 'ethereum.js.map'))) @@ -68,7 +68,7 @@ gulp.task('build', ['clean'], function () { .pipe(gulp.dest( DEST )); }); -gulp.task('uglify', ['build'], function(){ +gulp.task('build', ['prepare'], function(){ return gulp.src( DEST + 'ethereum.js') .pipe(uglify()) .pipe(rename('ethereum.min.js')) @@ -76,7 +76,7 @@ gulp.task('uglify', ['build'], function(){ }); gulp.task('watch', function() { - gulp.watch(['./lib/*.js'], ['lint', 'build', 'uglify']); + gulp.watch(['./lib/*.js'], ['lint', 'prepare', 'build']); }); -gulp.task('default', ['bower', 'lint', 'build', 'uglify']); +gulp.task('default', ['bower', 'lint', 'prepare', 'build']); -- cgit v1.2.3 From 4b876168f4db1f339d8d1a222a3ccb9a3f756957 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 11 Nov 2014 10:45:38 +0100 Subject: gulp qt task --- gulpfile.js | 68 ++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 120e4532d..a66aaacdb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,27 +16,9 @@ var source = require('vinyl-source-stream'); var exorcist = require('exorcist'); var bower = require('bower'); - var DEST = './dist/'; -gulp.task('bower', function(cb){ - bower.commands.install().on('end', function (installed){ - console.log(installed); - cb(); - }); -}); - -gulp.task('lint', function(){ - return gulp.src(['./*.js', './lib/*.js']) - .pipe(jshint()) - .pipe(jshint.reporter('default')); -}); - -gulp.task('clean', ['lint'], function(cb) { - del([ DEST ], cb); -}); - -gulp.task('build', ['clean'], function () { +var build = function(src, dst) { return browserify({ debug: true, insert_global_vars: false, @@ -44,7 +26,7 @@ gulp.task('build', ['clean'], function () { bundleExternal: false }) .add('./') - .require('./index.js', {expose: 'web3'}) + .require('./' + src + '.js', {expose: 'web3'}) .transform('envify', { NODE_ENV: 'build' }) @@ -63,16 +45,49 @@ gulp.task('build', ['clean'], function () { warnings: true, }) .bundle() - .pipe(exorcist(path.join( DEST, 'ethereum.js.map'))) - .pipe(source('ethereum.js')) + .pipe(exorcist(path.join( DEST, dst + '.js.map'))) + .pipe(source(dst + '.js')) .pipe(gulp.dest( DEST )); -}); +}; -gulp.task('uglify', ['build'], function(){ - return gulp.src( DEST + 'ethereum.js') +var uglifyFile = function(file) { + return gulp.src( DEST + file + '.js') .pipe(uglify()) - .pipe(rename('ethereum.min.js')) + .pipe(rename(file + '.min.js')) .pipe(gulp.dest( DEST )); +}; + +gulp.task('bower', function(cb){ + bower.commands.install().on('end', function (installed){ + console.log(installed); + cb(); + }); +}); + +gulp.task('lint', function(){ + return gulp.src(['./*.js', './lib/*.js']) + .pipe(jshint()) + .pipe(jshint.reporter('default')); +}); + +gulp.task('clean', ['lint'], function(cb) { + del([ DEST ], cb); +}); + +gulp.task('build', ['clean'], function () { + return build('index', 'ethereum'); +}); + +gulp.task('buildQt', ['clean'], function () { + return build('index_qt', 'ethereum_qt'); +}); + +gulp.task('uglify', ['build'], function(){ + return uglifyFile('ethereum'); +}); + +gulp.task('uglifyQt', ['buildQt'], function () { + return uglifyFile('ethereum_qt'); }); gulp.task('watch', function() { @@ -80,3 +95,4 @@ gulp.task('watch', function() { }); gulp.task('default', ['bower', 'lint', 'build', 'uglify']); +gulp.task('qt', ['bower', 'lint', 'buildQt', 'uglifyQt']); -- cgit v1.2.3 From 838ca2fd9393e5b3cd4423934de78f1b8f9fd13f Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 11 Nov 2014 15:47:58 +0100 Subject: autoprovider, buildQt not builds only necessery files, fixed gulpfile --- gulpfile.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 7758a38e0..9e0717d8b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,8 +25,8 @@ var build = function(src, dst) { detectGlobals: false, bundleExternal: false }) - .add('./') .require('./' + src + '.js', {expose: 'web3'}) + .add('./' + src + '.js') .transform('envify', { NODE_ENV: 'build' }) @@ -50,6 +50,25 @@ var build = function(src, dst) { .pipe(gulp.dest( DEST )); }; +var buildDev = function(src, dst) { + return browserify({ + debug: true, + insert_global_vars: false, + detectGlobals: false, + bundleExternal: false + }) + .require('./' + src + '.js', {expose: 'web3'}) + .add('./' + src + '.js') + .transform('envify', { + NODE_ENV: 'build' + }) + .transform('unreachable-branch-transform') + .bundle() + .pipe(exorcist(path.join( DEST, dst + '.js.map'))) + .pipe(source(dst + '.js')) + .pipe(gulp.dest( DEST )); +}; + var uglifyFile = function(file) { return gulp.src( DEST + file + '.js') .pipe(uglify()) @@ -79,7 +98,11 @@ gulp.task('build', ['clean'], function () { }); gulp.task('buildQt', ['clean'], function () { - return build('index_qt', 'ethereum_qt'); + return build('index_qt', 'ethereum'); +}); + +gulp.task('buildDev', ['clean'], function () { + return buildDev('index', 'ethereum'); }); gulp.task('uglify', ['build'], function(){ @@ -87,7 +110,7 @@ gulp.task('uglify', ['build'], function(){ }); gulp.task('uglifyQt', ['buildQt'], function () { - return uglifyFile('ethereum_qt'); + return uglifyFile('ethereum'); }); gulp.task('watch', function() { @@ -96,3 +119,5 @@ gulp.task('watch', function() { gulp.task('default', ['bower', 'lint', 'build', 'uglify']); gulp.task('qt', ['bower', 'lint', 'buildQt', 'uglifyQt']); +gulp.task('dev', ['bower', 'lint', 'buildDev']); + -- cgit v1.2.3