build - add gulp build process

feature/default_network_editable
kumavis 9 years ago
parent 6df64970aa
commit f52f4d460e
  1. 4
      .gitignore
  2. 1228
      app/scripts/chromereload.js
  3. 131
      gulpfile.js
  4. 13
      package.json

4
.gitignore vendored

@ -1,7 +1,9 @@
dist
gulp-dist
node_modules
temp
.tmp
dist
.sass-cache
app/bower_components
test/bower_components

File diff suppressed because it is too large Load Diff

@ -0,0 +1,131 @@
var watchify = require('watchify')
var browserify = require('browserify')
var gulp = require('gulp')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var gutil = require('gulp-util')
var watch = require('gulp-watch')
var sourcemaps = require('gulp-sourcemaps')
var assign = require('lodash.assign')
var livereload = require('gulp-livereload')
var del = require('del')
// browser reload
gulp.task('dev:reload', function() {
livereload.listen({
port: 35729,
// basePath: './gulp-dist/'
})
})
// copy static
gulp.task('copy:locales', copyTask({
source: './app/_locales/',
destination: './gulp-dist/_locales',
}))
gulp.task('copy:images', copyTask({
source: './app/images/',
destination: './gulp-dist/images',
}))
gulp.task('copy:reload', copyTask({
source: './app/scripts/',
destination: './gulp-dist/scripts',
pattern: '/chromereload.js',
}))
gulp.task('copy:root', copyTask({
source: './app/',
destination: './gulp-dist',
pattern: '/*',
}))
gulp.task('copy', gulp.parallel('copy:locales','copy:images','copy:reload','copy:root'))
gulp.task('copy:watch', function(){
gulp.watch(['./app/{_locales,images}/', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy'))
})
// build js
gulp.task('dev:js:inpage', bundleTask({ watch: true, filename: 'inpage.js' }))
gulp.task('dev:js:contentscript', bundleTask({ watch: true, filename: 'contentscript.js' }))
gulp.task('dev:js:background', bundleTask({ watch: true, filename: 'background.js' }))
gulp.task('dev:js:popup', bundleTask({ watch: true, filename: 'popup.js' }))
gulp.task('dev:js', gulp.parallel('dev:js:inpage','dev:js:contentscript','dev:js:background','dev:js:popup'))
gulp.task('build:js:inpage', bundleTask({ watch: false, filename: 'inpage.js' }))
gulp.task('build:js:contentscript', bundleTask({ watch: false, filename: 'contentscript.js' }))
gulp.task('build:js:background', bundleTask({ watch: false, filename: 'background.js' }))
gulp.task('build:js:popup', bundleTask({ watch: false, filename: 'popup.js' }))
gulp.task('build:js', gulp.parallel('build:js:inpage','build:js:contentscript','build:js:background','build:js:popup'))
// clean dist
gulp.task('clean', function clean() {
return del(['./gulp-dist'])
})
// high level tasks
gulp.task('dev', gulp.series('dev:js', 'copy', gulp.parallel('copy:watch', 'dev:reload')))
gulp.task('build', gulp.series('clean', gulp.parallel('build:js', 'copy')))
// task generators
function copyTask(opts){
var source = opts.source
var destination = opts.destination
var pattern = opts.pattern || '/**/*'
return performCopy
function performCopy(){
return (
gulp.src(source + pattern, { base: source })
.pipe(gulp.dest(destination))
.pipe(livereload())
)
}
}
function bundleTask(opts) {
var browserifyOpts = assign({}, watchify.args, {
entries: ['./app/scripts/'+opts.filename],
debug: true,
})
var bundler = browserify(browserifyOpts)
if (opts.watch) {
bundler = watchify(bundler)
bundler.on('update', performBundle) // on any dep update, runs the bundler
}
bundler.on('log', gutil.log) // output build logs to terminal
return performBundle
function performBundle(){
return (
bundler.bundle()
// log errors if they happen
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source(opts.filename))
// optional, remove if you don't need to buffer file contents
.pipe(buffer())
// optional, remove if you dont want sourcemaps
.pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
// Add transformation tasks to the pipeline here.
.pipe(sourcemaps.write('./')) // writes .map file
.pipe(gulp.dest('./gulp-dist/scripts'))
.pipe(livereload())
)
}
}

@ -12,19 +12,21 @@
"clone": "^1.0.2",
"dnode": "^1.2.2",
"end-of-stream": "^1.1.0",
"eth-lightwallet": "^1.0.1",
"eth-lightwallet": "^2.2.2",
"eth-store": "^1.1.0",
"ethereumjs-tx": "^0.6.7",
"ethereumjs-tx": "^1.0.0",
"ethereumjs-util": "^1.3.5",
"faux-jax": "git+https://github.com/kumavis/faux-jax.git#c3648de04804f3895c5b4972750cae5b51ddb103",
"inject-css": "^0.1.1",
"metamask-ui": "^1.3.0",
"readable-stream": "^2.0.5",
"web3": "^0.15.1",
"web3-provider-engine": "^5.1.1",
"web3-provider-engine": "^6.0.3",
"xtend": "^4.0.1"
},
"devDependencies": {
"del": "^2.2.0",
"browser-sync": "^2.11.1",
"grunt": "~0.4.1",
"grunt-browserify": "^4.0.0",
"grunt-chrome-manifest": "~0.2.0",
@ -34,12 +36,15 @@
"grunt-contrib-connect": "~0.7.1",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-imagemin": "~0.7.1",
"grunt-svgmin": "~0.4.0",
"grunt-contrib-jshint": "~0.9.2",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-mocha": "~0.4.10",
"grunt-svgmin": "~0.4.0",
"grunt-usemin": "~2.1.0",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-livereload": "^3.8.1",
"gulp-watch": "^4.3.5",
"jshint-stylish": "~0.1.5",
"load-grunt-tasks": "~0.4.0",
"time-grunt": "~0.3.1"

Loading…
Cancel
Save