-
Notifications
You must be signed in to change notification settings - Fork 125
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
1 parent
a008b1c
commit 15b6df9
Showing
33 changed files
with
46,868 additions
and
111 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 |
---|---|---|
@@ -1,30 +1,4 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# Commenting this out is preferred by some people, see | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- | ||
node_modules | ||
|
||
# Users Environment Variables | ||
.lock-wscript | ||
.DS_Store | ||
build/ | ||
build/index.html | ||
build/test.js | ||
node_modules |
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 |
---|---|---|
@@ -1,94 +1,130 @@ | ||
var gulp = require('gulp'); | ||
var source = require('vinyl-source-stream'); // Used to stream bundle for further handling | ||
var browserify = require('browserify'); | ||
var watchify = require('watchify'); | ||
var source = require('vinyl-source-stream'); | ||
var reactify = require('reactify'); | ||
var gulpif = require('gulp-if'); | ||
var uglify = require('gulp-uglify'); | ||
var streamify = require('gulp-streamify'); | ||
var notify = require('gulp-notify'); | ||
var gutil = require('gulp-util'); | ||
var package = require('./package.json'); | ||
var shell = require('gulp-shell'); | ||
var reactify = require('reactify'); | ||
var livereload = require('gulp-livereload'); | ||
var glob = require('glob'); | ||
var jasminePhantomJs = require('gulp-jasmine2-phantomjs'); | ||
var fs = require('fs'); | ||
|
||
var dependencies = ['react']; | ||
|
||
var browserifyTask = function (options) { | ||
|
||
// Our app bundler | ||
var appBundler = browserify({ | ||
entries: [options.src], | ||
transform: [reactify], | ||
debug: options.development, | ||
cache: {}, | ||
packageCache: {}, | ||
fullPaths: options.development | ||
}); | ||
|
||
// The task that handles both development and deployment | ||
var runBrowserifyTask = function (options) { | ||
|
||
// This bundle is for our application | ||
var bundler = browserify({ | ||
debug: options.debug, // Need that sourcemapping | ||
standalone: 'Formsy', | ||
// These options are just for Watchify | ||
cache: {}, packageCache: {}, fullPaths: options.watch | ||
}) | ||
.require(require.resolve('./src/main.js'), { entry: true }) | ||
.transform(reactify) // Transform JSX | ||
.external('react'); | ||
|
||
// The actual rebundle process | ||
appBundler.external(dependencies); | ||
|
||
// The rebundle process | ||
var rebundle = function () { | ||
var start = Date.now(); | ||
bundler.bundle() | ||
var fileName = options.uglify ? 'formsy-react.min.js' : 'formsy-react.js'; | ||
console.log('Building APP bundle'); | ||
appBundler.bundle() | ||
.on('error', gutil.log) | ||
.pipe(source(options.name)) | ||
.pipe(source(fileName)) | ||
.pipe(gulpif(options.uglify, streamify(uglify()))) | ||
.pipe(gulp.dest(options.dest)) | ||
.pipe(notify(function () { | ||
console.log('APP bundle built in ' + (Date.now() - start) + 'ms'); | ||
|
||
/* | ||
// Fix for requirejs | ||
var fs = require('fs'); | ||
var file = fs.readFileSync(options.dest + '/' + options.name).toString(); | ||
var file = fs.readFileSync(options.dest + '/' + fileName).toString(); | ||
file = file.replace('define([],e)', 'define(["react"],e)'); | ||
fs.writeFileSync(options.dest + '/' + options.name, file); | ||
|
||
console.log('Built in ' + (Date.now() - start) + 'ms'); | ||
|
||
fs.writeFileSync(options.dest + '/' + fileName, file); | ||
*/ | ||
})); | ||
|
||
}; | ||
|
||
// Fire up Watchify when developing | ||
if (options.watch) { | ||
bundler = watchify(bundler); | ||
bundler.on('update', rebundle); | ||
if (options.development) { | ||
appBundler = watchify(appBundler); | ||
appBundler.on('update', rebundle); | ||
} | ||
|
||
return rebundle(); | ||
rebundle(); | ||
|
||
// We create a separate bundle for our dependencies as they | ||
// should not rebundle on file changes. This only happens when | ||
// we develop. When deploying the dependencies will be included | ||
// in the application bundle | ||
if (options.development) { | ||
|
||
var testFiles = glob.sync('./specs/**/*-spec.js'); | ||
var testBundler = browserify({ | ||
entries: testFiles, | ||
debug: true, | ||
transform: [reactify], | ||
cache: {}, | ||
packageCache: {}, | ||
fullPaths: true | ||
}); | ||
|
||
testBundler.external(dependencies); | ||
|
||
var rebundleTests = function () { | ||
var start = Date.now(); | ||
console.log('Building TEST bundle'); | ||
testBundler.bundle() | ||
.on('error', gutil.log) | ||
.pipe(source('specs.js')) | ||
.pipe(gulp.dest(options.dest)) | ||
.pipe(livereload()) | ||
.pipe(notify(function () { | ||
console.log('TEST bundle built in ' + (Date.now() - start) + 'ms'); | ||
})); | ||
}; | ||
|
||
testBundler = watchify(testBundler); | ||
testBundler.on('update', rebundleTests); | ||
rebundleTests(); | ||
|
||
}; | ||
} | ||
|
||
} | ||
|
||
// Starts our development workflow | ||
gulp.task('default', function () { | ||
|
||
runBrowserifyTask({ | ||
watch: true, | ||
dest: './build', | ||
uglify: false, | ||
debug: true, | ||
name: 'formsy-react.js' | ||
livereload.listen({ basePath: 'specs' }); | ||
browserifyTask({ | ||
development: true, | ||
src: './src/main.js', | ||
dest: './build' | ||
}); | ||
|
||
}); | ||
|
||
gulp.task('deploy', function () { | ||
|
||
runBrowserifyTask({ | ||
watch: false, | ||
dest: './releases', | ||
uglify: true, | ||
debug: false, | ||
name: 'formsy-react.min.js' | ||
browserifyTask({ | ||
development: false, | ||
src: './src/main.js', | ||
dest: './release' | ||
}); | ||
|
||
runBrowserifyTask({ | ||
watch: false, | ||
dest: './releases', | ||
uglify: false, | ||
debug: false, | ||
name: 'formsy-react.js' | ||
browserifyTask({ | ||
development: false, | ||
src: './src/main.js', | ||
dest: './release', | ||
uglify: true | ||
}); | ||
|
||
}); | ||
|
||
gulp.task('test', shell.task([ | ||
'./node_modules/.bin/jasmine-node ./specs --autotest --watch ./src --color' | ||
])); |
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.