gulp qt task

This commit is contained in:
Marek Kotewicz 2014-11-11 10:45:38 +01:00
parent d92a7527db
commit 4b876168f4
2 changed files with 54 additions and 34 deletions

View File

@ -16,9 +16,47 @@ var source = require('vinyl-source-stream');
var exorcist = require('exorcist'); var exorcist = require('exorcist');
var bower = require('bower'); var bower = require('bower');
var DEST = './dist/'; var DEST = './dist/';
var build = function(src, dst) {
return browserify({
debug: true,
insert_global_vars: false,
detectGlobals: false,
bundleExternal: false
})
.add('./')
.require('./' + src + '.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, dst + '.js.map')))
.pipe(source(dst + '.js'))
.pipe(gulp.dest( DEST ));
};
var uglifyFile = function(file) {
return gulp.src( DEST + file + '.js')
.pipe(uglify())
.pipe(rename(file + '.min.js'))
.pipe(gulp.dest( DEST ));
};
gulp.task('bower', function(cb){ gulp.task('bower', function(cb){
bower.commands.install().on('end', function (installed){ bower.commands.install().on('end', function (installed){
console.log(installed); console.log(installed);
@ -37,42 +75,19 @@ gulp.task('clean', ['lint'], function(cb) {
}); });
gulp.task('build', ['clean'], function () { gulp.task('build', ['clean'], function () {
return browserify({ return build('index', 'ethereum');
debug: true, });
insert_global_vars: false,
detectGlobals: false, gulp.task('buildQt', ['clean'], function () {
bundleExternal: false return build('index_qt', 'ethereum_qt');
})
.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('uglify', ['build'], function(){ gulp.task('uglify', ['build'], function(){
return gulp.src( DEST + 'ethereum.js') return uglifyFile('ethereum');
.pipe(uglify()) });
.pipe(rename('ethereum.min.js'))
.pipe(gulp.dest( DEST )); gulp.task('uglifyQt', ['buildQt'], function () {
return uglifyFile('ethereum_qt');
}); });
gulp.task('watch', function() { gulp.task('watch', function() {
@ -80,3 +95,4 @@ gulp.task('watch', function() {
}); });
gulp.task('default', ['bower', 'lint', 'build', 'uglify']); gulp.task('default', ['bower', 'lint', 'build', 'uglify']);
gulp.task('qt', ['bower', 'lint', 'buildQt', 'uglifyQt']);

4
index_qt.js Normal file
View File

@ -0,0 +1,4 @@
var web3 = require('./lib/main');
web3.providers.QtProvider = require('./lib/qt');
module.exports = web3;