Skip to content

Commit 8000d62

Browse files
committed
Use vinyl-buffer to combine compile + minify steps
1 parent c29f292 commit 8000d62

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

dist/bespoke.js

100644100755
File mode changed.

dist/bespoke.min.js

100644100755
File mode changed.

gulpfile.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var gulp = require('gulp'),
2+
gutil = require('gulp-util'),
23
clean = require('gulp-clean'),
34
jshint = require('gulp-jshint'),
45
map = require('vinyl-map'),
@@ -7,21 +8,21 @@ var gulp = require('gulp'),
78
coveralls = require('gulp-coveralls'),
89
header = require('gulp-header'),
910
uglify = require('gulp-uglify'),
10-
streamify = require('gulp-streamify'),
1111
gzip = require('gulp-gzip'),
1212
micro = require('gulp-micro'),
1313
pkg = require('./package.json'),
1414
browserify = require('browserify'),
1515
source = require('vinyl-source-stream'),
16+
buffer = require('vinyl-buffer'),
17+
rename = require('gulp-rename'),
1618
path = require('path'),
1719
template = require('lodash').template;
1820

19-
gulp.task('default', ['clean', 'jshint', 'karma', 'build']);
20-
gulp.task('build', ['compile', 'minify']);
21-
gulp.task('dev', ['build', 'watch']);
21+
gulp.task('default', ['clean', 'jshint', 'karma', 'compile']);
22+
gulp.task('dev', ['compile', 'watch']);
2223

2324
gulp.task('watch', function() {
24-
gulp.watch('src/**/*.js', ['karma', 'build']);
25+
gulp.watch('src/**/*.js', ['karma', 'compile']);
2526
gulp.watch('test/spec/**/*.js', ['karma']);
2627
});
2728

@@ -56,35 +57,30 @@ gulp.task('coveralls', ['karma'], function() {
5657
.pipe(coveralls());
5758
});
5859

59-
var makeBundleStream = function(filename) {
60+
gulp.task('compile', ['clean'], function() {
6061
return browserify('./src/bespoke.js')
6162
.bundle({ standalone: 'bespoke' })
62-
.pipe(source(filename));
63-
};
64-
65-
gulp.task('compile', ['clean'], function() {
66-
return makeBundleStream('bespoke.js')
67-
.pipe(streamify(header(template([
63+
.on('error', gutil.log)
64+
.pipe(source('bespoke.js'))
65+
.pipe(buffer())
66+
.pipe(header(template([
6867
'/*!',
6968
' * <%= title %> v<%= version %>',
7069
' *',
7170
' * Copyright <%= new Date().getFullYear() %>, <%= author.name %>',
7271
' * This content is released under the <%= licenses[0].type %> license',
7372
' * <%= licenses[0].url %>',
7473
' */\n\n'
75-
].join('\n'), pkg))))
76-
.pipe(gulp.dest('dist'));
77-
});
78-
79-
gulp.task('minify', ['clean'], function() {
80-
return makeBundleStream('bespoke.min.js')
81-
.pipe(streamify(uglify()))
82-
.pipe(streamify(header(template([
83-
'/*! <%= title %> v<%= version %> ',
84-
'© <%= author.name %>, ',
85-
'<%= licenses[0].type %> License */\n'
86-
].join(''), pkg))))
87-
.pipe(gulp.dest('dist'))
88-
.pipe(gzip())
89-
.pipe(streamify(micro({ limit: 1024 })));
74+
].join('\n'), pkg)))
75+
.pipe(gulp.dest('dist'))
76+
.pipe(rename('bespoke.min.js'))
77+
.pipe(uglify())
78+
.pipe(header(template([
79+
'/*! <%= title %> v<%= version %> ',
80+
'© <%= author.name %>, ',
81+
'<%= licenses[0].type %> License */\n'
82+
].join(''), pkg)))
83+
.pipe(gulp.dest('dist'))
84+
.pipe(gzip())
85+
.pipe(micro({ limit: 1024 }));
9086
});

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222
"devDependencies": {
2323
"browserify": "~4.1.5",
2424
"function-bind": "~0.1.0",
25-
"gulp": "~3.5.1",
25+
"gulp": "^3.8.0",
2626
"gulp-clean": "~0.2.4",
2727
"gulp-coveralls": "~0.1.0",
2828
"gulp-gzip": "0.0.8",
2929
"gulp-header": "~1.0.2",
3030
"gulp-jshint": "~1.3.4",
3131
"gulp-karma": "0.0.2",
3232
"gulp-micro": "~0.1.2",
33-
"gulp-rename": "~0.2.2",
34-
"gulp-streamify": "0.0.5",
33+
"gulp-rename": "^1.2.0",
3534
"gulp-uglify": "~0.3.0",
3635
"istanbul": "^0.2.11",
3736
"jshint-stylish": "~0.1.5",
@@ -44,7 +43,9 @@
4443
"lodash": "~2.4.1",
4544
"requirejs": "~2.1.10",
4645
"vinyl-map": "^1.0.1",
47-
"vinyl-source-stream": "~0.1.1"
46+
"vinyl-source-stream": "~0.1.1",
47+
"vinyl-buffer": "0.0.0",
48+
"gulp-util": "^2.2.16"
4849
},
4950
"licenses": [
5051
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy