diff --git a/.gitignore b/.gitignore index ef54795..6202e12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ example_user/ node_modules/ test/ +webapp/dist/ diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..5fc604a --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,56 @@ +var gulp = require('gulp') +var source = require('vinyl-source-stream') +var buffer = require('vinyl-buffer') +var minifyCss = require('gulp-minify-css') +var browserify = require('browserify') +var reactify = require('reactify') // Transforms React JSX to JS +var uglify = require('gulp-uglify') +var clean = require('gulp-clean') + +var config = { + files: { + css: 'webapp/*.css', + js: 'webapp/*.js', + html: 'webapp/*.html', + mainJs: 'webapp/app.js' + }, + dest: 'webapp/dist/' +} + +config.browserify = browserify({ + entries: config.files.mainJs, + transform: [ reactify ] +}) + +gulp.task('css',function(){ + gulp.src(config.files.css) + .pipe(minifyCss()) + .pipe(gulp.dest(config.dest)) +}) + +gulp.task('html',function(){ + gulp.src(config.files.html) + .pipe(gulp.dest(config.dest)) +}) + +gulp.task('js',function(){ + config.browserify.bundle() + .on('error', console.error.bind(console)) + .pipe(source('app.js')) // do this or browserify won't work + .pipe(buffer()) // do this or uglify won't work + .pipe(uglify()) + .pipe(gulp.dest(config.dest)) +}) + +gulp.task('clean',function(){ + gulp.src(config.dest, { read: false }) + .pipe(clean()) +}) + +gulp.task('watch',function(){ + gulp.watch(config.files.js,['js']) + gulp.watch(config.files.html,['html']) + gulp.watch(config.files.css,['css']) +}) + +gulp.task('default', [ 'html', 'css', 'js', 'watch' ]) diff --git a/package.json b/package.json index f3f3bd0..df889c3 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,17 @@ "author": "Enrico Fasoli (fazo96)", "license": "MIT", "dependencies": { + "browserify": "^12.0.1", "commander": "^2.9.0", "express": "^4.13.3", + "gulp": "^3.9.0", + "gulp-clean": "^0.3.1", + "gulp-minify-css": "^1.2.1", + "gulp-uglify": "^1.5.1", "ipfs-api": "^2.6.2", - "moment": "^2.10.6" + "moment": "^2.10.6", + "reactify": "^1.1.1", + "vinyl-buffer": "^1.0.0", + "vinyl-source-stream": "^1.1.0" } } diff --git a/webapp/index.html b/webapp/index.html index 7343718..d5db752 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -1,17 +1,9 @@ IPFS Board - - - - - - - - - - -
+ + Loading... +