Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed repetitive bundle tasks #22

Merged
merged 2 commits into from
Jun 29, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed 2 spaces -> 4 spaces
leftiness committed Jun 29, 2015
commit d3337fdcbd02a70973378c6e9608b2706d1fee2d
54 changes: 27 additions & 27 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -174,45 +174,45 @@ gulp.task('checkstyle', function() {

var bundle = {};
bundle.conf = {
entries: filePath.browserify.src,
external: filePath.vendorJS.src,
debug: true,
cache: {},
packageCache: {}
entries: filePath.browserify.src,
external: filePath.vendorJS.src,
debug: true,
cache: {},
packageCache: {}
};

function rebundle() {
return bundle.bundler.bundle()
.pipe(source('bundle.js'))
.on('error', handleError)
.pipe(buffer())
.pipe(gulpif(!bundle.prod, sourcemaps.init({
loadMaps: true
})))
.pipe(gulpif(!bundle.prod, sourcemaps.write('./')))
.pipe(gulpif(bundle.prod, streamify(uglify({
mangle: false
}))))
.pipe(gulp.dest(filePath.build.dest))
.pipe(connect.reload());
return bundle.bundler.bundle()
.pipe(source('bundle.js'))
.on('error', handleError)
.pipe(buffer())
.pipe(gulpif(!bundle.prod, sourcemaps.init({
loadMaps: true
})))
.pipe(gulpif(!bundle.prod, sourcemaps.write('./')))
.pipe(gulpif(bundle.prod, streamify(uglify({
mangle: false
}))))
.pipe(gulp.dest(filePath.build.dest))
.pipe(connect.reload());
}

function configureBundle(prod) {
bundle.bundler = watchify(browserify(bundle.conf));
bundle.bundler.on('update', rebundle);
bundle.prod = prod;
bundle.bundler = watchify(browserify(bundle.conf));
bundle.bundler.on('update', rebundle);
bundle.prod = prod;
}

gulp.task('bundle-dev', function () {
'use strict';
configureBundle(false);
return rebundle();
'use strict';
configureBundle(false);
return rebundle();
});

gulp.task('bundle-prod', function () {
'use strict';
configureBundle(true);
return rebundle();
'use strict';
configureBundle(true);
return rebundle();
});