1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-10 12:24:20 +01:00
ipfs-boards/gulpfile.js

81 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2015-11-14 00:57:36 +01:00
var gulp = require('gulp')
2015-11-20 14:20:06 +01:00
var webpack = require('webpack-stream')
2015-11-14 00:57:36 +01:00
var clean = require('gulp-clean')
2015-11-14 01:34:03 +01:00
var connect = require('gulp-connect')
2015-11-19 18:06:45 +01:00
var ghPages = require('gulp-gh-pages')
2015-12-11 19:43:35 +01:00
var ipfsd = require('ipfsd-ctl')
2015-11-14 00:57:36 +01:00
var config = {
files: {
2015-11-14 01:34:03 +01:00
mainJs: 'webapp/app.jsx',
2015-11-14 00:57:36 +01:00
css: 'webapp/*.css',
2015-11-14 01:34:03 +01:00
js: ['webapp/*.js','webapp/*.jsx'],
2015-11-14 15:03:38 +01:00
html: 'webapp/*.html',
jsLibs: 'lib/*.js'
2015-11-14 00:57:36 +01:00
},
dest: 'webapp/dist/'
}
2015-12-11 19:43:35 +01:00
var server = {
root: config.dest,
port: 9090,
livereload: true
}
2015-11-20 20:31:54 +01:00
gulp.task('watch',['clean'],function(){
2015-11-20 14:20:06 +01:00
var cfg = require('./webpack.config.js')
cfg.watch = true
2015-11-20 20:31:54 +01:00
cfg.devtool = 'eval'
2015-11-20 14:20:06 +01:00
return gulp.src(config.files.mainJs)
.pipe(webpack(cfg))
.pipe(gulp.dest(config.dest))
.pipe(connect.reload())
2015-11-14 00:57:36 +01:00
})
2015-11-20 20:31:54 +01:00
gulp.task('build',['clean'],function(){
2015-11-20 14:20:06 +01:00
return gulp.src(config.files.mainJs)
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest(config.dest))
2015-11-14 00:57:36 +01:00
})
gulp.task('clean',function(){
2015-11-15 21:34:41 +01:00
return gulp.src(config.dest, { read: false }).pipe(clean())
2015-11-14 00:57:36 +01:00
})
gulp.task('server',function(){
2015-12-11 19:43:35 +01:00
connect.server(server)
2015-11-14 01:34:03 +01:00
})
2015-11-20 14:20:06 +01:00
gulp.task('gh-pages',[ 'build' ],function(){
2015-11-19 18:06:45 +01:00
gulp.src([config.dest+'*.js',config.dest+'*.css',config.dest+'*.html'])
.pipe(ghPages())
})
2015-12-11 19:43:35 +01:00
gulp.task('ipfs', function(done){
console.log(server.port)
//'API.HTTPHeaders.Access-Control-Allow-Origin': '*'
var opt = {
'Addresses.API': '/ip4/127.0.0.1/tcp/5001',
'API': {
'HTTPHeaders': {
'Access-Control-Allow-Origin': [
'*'
]
}
}
}
console.log(opt)
ipfsd.disposableApi(opt,(err, ipfs) => {
ipfs.id(function (err, id) {
if(err) return console.log('Failed to start IPFS:',err)
console.log('Started IPFS Daemon')
//done()
})
})
})
2015-11-20 14:20:06 +01:00
gulp.task('serve', [ 'watch', 'server' ])
2015-12-11 19:43:35 +01:00
gulp.task('serve-with-ipfs', [ 'serve', 'ipfs' ])
2015-11-20 14:20:06 +01:00
gulp.task('default', [ 'build' ])