mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-03-12 21:48:39 +01:00
added livereload, restructured files
This commit is contained in:
parent
92952711cb
commit
ecc9d00d1d
20
gulpfile.js
20
gulpfile.js
@ -6,13 +6,14 @@ var browserify = require('browserify')
|
|||||||
var reactify = require('reactify') // Transforms React JSX to JS
|
var reactify = require('reactify') // Transforms React JSX to JS
|
||||||
var uglify = require('gulp-uglify')
|
var uglify = require('gulp-uglify')
|
||||||
var clean = require('gulp-clean')
|
var clean = require('gulp-clean')
|
||||||
|
var connect = require('gulp-connect')
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
files: {
|
files: {
|
||||||
|
mainJs: 'webapp/app.jsx',
|
||||||
css: 'webapp/*.css',
|
css: 'webapp/*.css',
|
||||||
js: 'webapp/*.js',
|
js: ['webapp/*.js','webapp/*.jsx'],
|
||||||
html: 'webapp/*.html',
|
html: 'webapp/*.html'
|
||||||
mainJs: 'webapp/app.js'
|
|
||||||
},
|
},
|
||||||
dest: 'webapp/dist/'
|
dest: 'webapp/dist/'
|
||||||
}
|
}
|
||||||
@ -21,11 +22,13 @@ gulp.task('css',function(){
|
|||||||
gulp.src(config.files.css)
|
gulp.src(config.files.css)
|
||||||
.pipe(minifyCss())
|
.pipe(minifyCss())
|
||||||
.pipe(gulp.dest(config.dest))
|
.pipe(gulp.dest(config.dest))
|
||||||
|
.pipe(connect.reload())
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('html',function(){
|
gulp.task('html',function(){
|
||||||
gulp.src(config.files.html)
|
gulp.src(config.files.html)
|
||||||
.pipe(gulp.dest(config.dest))
|
.pipe(gulp.dest(config.dest))
|
||||||
|
.pipe(connect.reload())
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('js',function(){
|
gulp.task('js',function(){
|
||||||
@ -37,6 +40,7 @@ gulp.task('js',function(){
|
|||||||
.pipe(buffer()) // do this or uglify won't work
|
.pipe(buffer()) // do this or uglify won't work
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(gulp.dest(config.dest))
|
.pipe(gulp.dest(config.dest))
|
||||||
|
.pipe(connect.reload())
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('clean',function(){
|
gulp.task('clean',function(){
|
||||||
@ -44,10 +48,18 @@ gulp.task('clean',function(){
|
|||||||
.pipe(clean())
|
.pipe(clean())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gulp.task('serve',function(){
|
||||||
|
connect.server({
|
||||||
|
root: config.dest,
|
||||||
|
port: 9090,
|
||||||
|
livereload: true
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
gulp.task('watch',function(){
|
gulp.task('watch',function(){
|
||||||
gulp.watch(config.files.js,['js'])
|
gulp.watch(config.files.js,['js'])
|
||||||
gulp.watch(config.files.html,['html'])
|
gulp.watch(config.files.html,['html'])
|
||||||
gulp.watch(config.files.css,['css'])
|
gulp.watch(config.files.css,['css'])
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('default', [ 'html', 'css', 'js', 'watch' ])
|
gulp.task('default', [ 'html', 'css', 'js', 'watch', 'serve' ])
|
||||||
|
@ -27,7 +27,7 @@ module.exports = function(boards,options){
|
|||||||
options = options || {}
|
options = options || {}
|
||||||
|
|
||||||
// Serve web app
|
// Serve web app
|
||||||
app.use(express.static(__dirname+'/../webapp'))
|
app.use(express.static(__dirname+'/../webapp/dist/'))
|
||||||
|
|
||||||
app.get('/@:user',(req,res) => {
|
app.get('/@:user',(req,res) => {
|
||||||
boards.getProfile(req.params.user,apiToHandler(req,res))
|
boards.getProfile(req.params.user,apiToHandler(req,res))
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
"express": "^4.13.3",
|
"express": "^4.13.3",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
"gulp-clean": "^0.3.1",
|
"gulp-clean": "^0.3.1",
|
||||||
|
"gulp-connect": "^2.2.0",
|
||||||
"gulp-minify-css": "^1.2.1",
|
"gulp-minify-css": "^1.2.1",
|
||||||
"gulp-uglify": "^1.5.1",
|
"gulp-uglify": "^1.5.1",
|
||||||
"ipfs-api": "^2.6.2",
|
"ipfs-api": "^2.6.2",
|
||||||
|
@ -12,7 +12,7 @@ boards.init(function(err){
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
} else {
|
} else {
|
||||||
server = BoardsAPIHttp(boards)
|
server = BoardsAPIHttp(boards)
|
||||||
setInterval(boards.searchUsers.bind(boards),3 * 60 * 1000)
|
// setInterval(boards.searchUsers.bind(boards),3 * 60 * 1000)
|
||||||
boards.searchUsers()
|
// boards.searchUsers()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
7
webapp/app.jsx
Normal file
7
webapp/app.jsx
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
var React = require('react')
|
||||||
|
var ReactDOM = require('react-dom')
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<h1>Hello, world!</h1>,
|
||||||
|
document.getElementById('container')
|
||||||
|
);
|
@ -3,7 +3,7 @@
|
|||||||
<title>IPFS Board</title>
|
<title>IPFS Board</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Loading...
|
<div id="container">Loading...</div>
|
||||||
<script src="/app.js"></script>
|
<script src="/app.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user