Simplifying the "scripts" gulp task

This commit is contained in:
Jeff Avallone 2015-11-01 07:07:17 -05:00
parent 445996744a
commit c02fb6406b
2 changed files with 19 additions and 12 deletions

View File

@ -19,7 +19,7 @@ gulp.task('default', ['server', 'docs'], function() {
config.globs.partials,
config.globs.sass
]), ['markup']);
gulp.watch(config.globs.js, ['browserify', 'docs']);
gulp.watch(config.globs.js, ['scripts', 'docs']);
});
gulp.task('docs', ['docs:files'], function() {
@ -99,18 +99,24 @@ gulp.task('styles', function() {
gulp.task('scripts', function() {
var browserify = require('browserify'),
tap = require('gulp-tap');
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
sourcemaps = require('gulp-sourcemaps'),
rename = require('gulp-rename');
return gulp.src('./src/js/main.js', { read: false })
.pipe(errorHandler())
.pipe(tap(function(file) {
var bundler = browserify(config.browserify)
.transform(require('./lib/canopy-transform'))
.transform(require('babelify'))
.add(file.path);
var b = browserify(config.browserify)
.transform(require('./lib/canopy-transform'))
.transform(require('babelify'))
.add('./src/js/main.js');
file.contents = bundler.bundle();
return b.bundle()
.pipe(source('./src/js/main.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(rename(function(path) {
path.dirname = '';
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.buildPath('js')));
});

View File

@ -25,7 +25,6 @@
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.1.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-tap": "^0.1.3",
"handlebars-layouts": "^3.1.2",
"jasmine-core": "^2.3.4",
"karma": "^0.13.14",
@ -36,6 +35,8 @@
"lodash": "^3.10.1",
"node-bourbon": "^4.2.3",
"snapsvg": "^0.4.0",
"through": "^2.3.8"
"through": "^2.3.8",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
}
}