Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by granted on 3/5/15.
- */
- var gulp = require('gulp');
- var uglify = require('gulp-uglify');
- var source = require('vinyl-source-stream');
- var browserify = require('browserify');
- var watchify = require('watchify');
- var reactify = require('reactify');
- var streamify = require('gulp-streamify');
- var path = {
- OUT: 'build.js',
- VENDOR: 'vendor.js',
- DEST_SRC: 'public/js',
- ENTRY_POINT: './src/app/App.jsx'
- };
- var dependencies = [
- 'react',
- 'react-router',
- 'react-bootstrap',
- 'react-router-bootstrap'
- ];
- var buildTask = function(options) {
- var watcher = browserify({
- entries: [path.ENTRY_POINT],
- transform: [reactify],
- debug: options.development,
- cache: {}, packageCache: {}, fullPaths: true
- });
- watcher.external(dependencies);
- var updater = function() {
- console.log('Build');
- if (options.development) {
- watcher
- .bundle()
- .pipe(source(path.OUT))
- .pipe(gulp.dest(path.DEST_SRC))
- ;
- } else {
- watcher
- .bundle()
- .pipe(source(path.OUT))
- .pipe(streamify(uglify()))
- .pipe(gulp.dest(path.DEST_SRC))
- }
- };
- if (options.development) {
- watcher = watchify(watcher);
- watcher.on('update', updater);
- }
- updater();
- var vendorsBundler = browserify({
- debug: true,
- require: dependencies
- });
- vendorsBundler
- .bundle()
- .pipe(source(path.VENDOR))
- .pipe(streamify(uglify()))
- .pipe(gulp.dest(path.DEST_SRC))
- };
- gulp.task('watch', function() {
- buildTask({
- development: true
- });
- });
- gulp.task('deploy', function(){
- buildTask({
- development: false
- })
- });
- gulp.task('default', ['watch']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement