This repository has been archived by the owner on Aug 28, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ukatama
committed
Jan 18, 2016
1 parent
79538f2
commit eb77c9d
Showing
16 changed files
with
194 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"presets": [ | ||
"react", | ||
"es2015", | ||
"stage-2" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ bower_components | |
lib | ||
node_modules | ||
npm-debug.log | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict'; | ||
|
||
const browserify = require('browserify'); | ||
const fs = require('fs'); | ||
const gulp = require('gulp'); | ||
const babel = require('gulp-babel'); | ||
const express = require('gulp-express'); | ||
const gutil = require('gulp-util'); | ||
const source = require('vinyl-source-stream'); | ||
const buffer = require('vinyl-buffer'); | ||
const watchify = require('watchify'); | ||
|
||
gulp.task('default', ['build']); | ||
|
||
gulp.task('build', ['build:server', 'build:browser']); | ||
gulp.task('build:server', ['babel']); | ||
gulp.task('build:browser', ['browserify']); | ||
|
||
gulp.task('serve', ['express']); | ||
|
||
gulp.task('watch', ['watch:server', 'watch:browser']); | ||
gulp.task('watch:server', ['express'], () => { | ||
gulp.watch(['src/**/*', '!src/browser/**/*'], ['babel', express.run]); | ||
}); | ||
gulp.task('watch:browser', ['watchify'], () => | ||
gulp.watch(['src/**/*', '!src/server/**/*'], ['watchify'])); | ||
|
||
gulp.task( | ||
'sync-lib', | ||
next => { | ||
let read = (dir) => | ||
fs.readdirSync(dir) | ||
.map(item => `${dir}/${item}`) | ||
.map(item => | ||
fs.statSync(item).isDirectory() | ||
? read(item).concat([ item ]) | ||
: [ item ] | ||
) | ||
.reduce((a, b) => a.concat(b)); | ||
read('lib') | ||
.filter(item => !fs.existsSync(item.replace(/^lib/, 'src'))) | ||
.forEach(item => { | ||
gutil.log(`rm ${item}`); | ||
if (fs.statSync(item).isDirectory()) { | ||
fs.rmdirSync(item); | ||
} else { | ||
fs.unlinkSync(item); | ||
} | ||
}); | ||
return next(); | ||
} | ||
); | ||
|
||
gulp.task( | ||
'babel', ['sync-lib'], | ||
() => gulp.src('src/**/*.js') | ||
.pipe(babel()) | ||
.pipe(gulp.dest('lib')) | ||
); | ||
|
||
const BrowserifyConfig = { | ||
entries: ['lib/browser'], | ||
}; | ||
const bundle = function(b) { | ||
return function() { | ||
return b.bundle() | ||
.on('error', e => gutil.log(e)) | ||
.pipe(source('browser.js')) | ||
.pipe(buffer()) | ||
.pipe(gulp.dest('dist')); | ||
}; | ||
}; | ||
const w = watchify(browserify(Object.assign({}, watchify.args, BrowserifyConfig))); | ||
w.on('update', bundle); | ||
w.on('log', gutil.log); | ||
gulp.task('watchify', ['babel'], bundle(w)); | ||
gulp.task('browserify', ['babel'], bundle(browserify(BrowserifyConfig))); | ||
|
||
gulp.task('express', ['babel'], () => express.run(['.'])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.