diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 59d91e5..3b1074f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,20 +4,21 @@ You'll need: - __node and npm__: you can get these on Homebrew on OSX or in your Linux distro's repos - __git__: you can get it just like node and npm -- __gulp__: you can get it by running `npm install -g gulp`. It might require super user privileges +- __webpack and webpack-dev-server__: you can get them by running `npm install -g webpack webpack-dev-server`. It might require super user privileges - __go-ipfs__: you can get it like git and node, but not always, you may need to follow its istructions on its repo 1. Clone this repository and `cd` to its directory 1. run `npm install` to get dependences (there are many) -To use the app you'll need to have an IPFS daemon running. You can start one using `ipfs daemon` +To fully use the app you'll need to have an IPFS daemon running. You can start one using `ipfs daemon` -You will also need to enable CORS on your IPFS daemon. See or run the `ipfs_daemon_set_cors.sh` file +You will also need to enable CORS on your IPFS daemon. +See the `ipfs_daemon_set_cors.sh` file (__Security Tip:__ don't run it before reading it!!!) Now you can run: -- `gulp` to build the webapp inside `webapp/dist/` -- `gulp serve` to start a webserver that will serve you the app and rebuild it if you change some files +- `npm run build` to build the webapp inside `webapp/dist/` +- `npm run serve` to start a webserver that will serve you the app locally and automagically rebuild it if you change some files Have fun! diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 3b43d95..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,53 +0,0 @@ -var gulp = require('gulp') -var webpack = require('webpack-stream') -var clean = require('gulp-clean') -var connect = require('gulp-connect') -var ghPages = require('gulp-gh-pages') - -var config = { - files: { - mainJs: 'webapp/app.jsx', - css: 'webapp/*.css', - js: ['webapp/*.js','webapp/*.jsx'], - html: 'webapp/*.html', - jsLibs: 'lib/*.js' - }, - dest: 'webapp/dist/' -} - -gulp.task('watch',['clean'],function(){ - var cfg = require('./webpack.config.js') - cfg.watch = true - cfg.devtool = 'eval' - return gulp.src(config.files.mainJs) - .pipe(webpack(cfg)) - .pipe(gulp.dest(config.dest)) - .pipe(connect.reload()) -}) - -gulp.task('build',['clean'],function(){ - return gulp.src(config.files.mainJs) - .pipe(webpack(require('./webpack.config.js'))) - .pipe(gulp.dest(config.dest)) -}) - -gulp.task('clean',function(){ - return gulp.src(config.dest, { read: false }).pipe(clean()) -}) - -gulp.task('server',function(){ - connect.server({ - root: config.dest, - port: 9090, - livereload: true - }) -}) - -gulp.task('gh-pages',[ 'build' ],function(){ - gulp.src([config.dest+'*.js',config.dest+'*.css',config.dest+'*.html']) - .pipe(ghPages()) -}) - -gulp.task('serve', [ 'watch', 'server' ]) - -gulp.task('default', [ 'build' ]) diff --git a/ipfs_daemon_set_cors.sh b/ipfs_daemon_set_cors.sh index dc525cf..ed9d50a 100755 --- a/ipfs_daemon_set_cors.sh +++ b/ipfs_daemon_set_cors.sh @@ -3,7 +3,11 @@ # This will make sure your ipfs node works with the app. # NOTE: this change is PERMANENT until reversed! -# If you want a temporary solution, try running your daemon like this: +### IMPORTANT NOTE ABOUT SECURITY ### +# By setting these, YOU WILL ALLOW ANY STATIC WEBSITE TO FULLY CONTROL YOUR +# IPFS NODE! A solution for this problem, using API Tokens, is planned! + +# If you want a temporary way to set CORS, try running your daemon like this: # API_ORIGIN="localhost:8080" ipfs daemon # replace localhost:8080 with whatever domain:port you're connecting from :) # Also see https://github.com/ipfs/js-ipfs-api#cors diff --git a/package.json b/package.json index 2ba274b..9154fa2 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,8 @@ "version": "0.1.0", "description": "decentralized discussion board", "scripts": { - "serve": "gulp serve", - "build": "gulp" - }, - "bin": { - "ipfs-board": "cli.js" + "serve": "webpack-dev-server --progress --no-info", + "build": "webpack --progress" }, "repository": { "type": "git", @@ -31,10 +28,6 @@ "eslint-plugin-react": "~3.11.3", "file-loader": "~0.8.5", "font-awesome": "~4.5.0", - "gulp": "~3.9.0", - "gulp-clean": "~0.3.1", - "gulp-connect": "~2.2.0", - "gulp-gh-pages": "~0.5.4", "history": "~1.13.0", "html-loader": "^0.4.0", "html-webpack-plugin": "~1.7.0", @@ -50,7 +43,7 @@ "stream-http": "~2.0.2", "style-loader": "~0.13.0", "webpack": "~1.12.9", - "webpack-stream": "~3.0.1", + "webpack-dev-server": "^1.14.0", "wolfy87-eventemitter": "~4.3.0" } } diff --git a/publish_profile.sh b/publish_profile.sh index 4b0f53f..490ce0f 100755 --- a/publish_profile.sh +++ b/publish_profile.sh @@ -1,3 +1,2 @@ #!/bin/sh - ipfs name publish $(ipfs add -r -q -w $1 | tail -n1) diff --git a/upload_webapp_on_ipfs.sh b/upload_webapp_on_ipfs.sh index 21b2514..a63a81e 100755 --- a/upload_webapp_on_ipfs.sh +++ b/upload_webapp_on_ipfs.sh @@ -1,2 +1,2 @@ #!/bin/sh -gulp && echo "/ipfs/$(ipfs add -r -q webapp/dist | tail -n1)" +npm run build && echo "/ipfs/$(ipfs add -r -q webapp/dist | tail -n1)" diff --git a/webpack.config.js b/webpack.config.js index a5dd1db..10b6bfd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,9 +4,8 @@ var HtmlWebpackPlugin = require('html-webpack-plugin') // Most of the config was copied from js-ipfs-api's webpack configuration -module.exports = { - entry: './webapp/app.jsx', - debug: true, +var config = { + entry: path.join(__dirname,'webapp','app.jsx'), output: { path: path.join(__dirname,'webapp','dist'), filename: 'app.js' @@ -70,3 +69,18 @@ module.exports = { new webpack.optimize.DedupePlugin() ] } + +config.devServer = { + // webpack-dev-server -w --progress --devtool eval --port 9090 --quiet --content-base ./webapp/dist + watch: true, + progress: true, + debug: true, + devtool: 'eval-source', + port: 9090, + noInfo: true, + colors: true, + inline: true, + contentBase: config.output.path +}, + +module.exports = config