Last active
August 29, 2015 14:06
-
-
Save cognitom/f82afcc36072c6815a86 to your computer and use it in GitHub Desktop.
gulpfile スタイルガイド - v0.5.0 ref: http://qiita.com/cognitom/items/045c8596a30aa5ab8a47
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
var gulp = require('gulp'); | |
var browserify = require('browserify'); | |
var source = require('vinyl-source-stream'); |
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
var gulp = require('gulp') | |
,browserify = require('browserify') | |
,source = require('vinyl-source-stream'); |
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
var requireDir = require('require-dir'); | |
var dir = requireDir('./task'); |
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
var gulp = require('gulp'); | |
var del = require('del'); | |
var runSequence = require('run-sequence'); | |
var requireDir = require('require-dir'); | |
var dir = requireDir('./task'); | |
gulp.task('default', function (cb){ | |
runSequence('clean', 'icon', 'build', cb); // gulp.js 3.xでの書き方 | |
}); | |
gulp.task('clean', function(cb){ | |
del(['./dist'], cb); | |
}); | |
gulp.task('watch', function(){ | |
gulp.watch(['src/icon/*.svg'], { debounceDelay: 1000 }, ['icon']); | |
}); |
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
$ gulp --verify |
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
gulp.task('script', function() { | |
gulp.src('main.js') | |
.pipe(duo()) | |
.pipe(gulp.dest('dist')) | |
}) | |
function duo() { | |
return map(function(file, cb) { | |
Duo(file.base) | |
.src(file.contents.toString()); | |
.run(function(err, src) { | |
if (err) return cb(err); | |
file.contents = new Buffer(src); | |
cb(null, file); | |
}); | |
}); | |
} |
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
var foreach = require('gulp-foreach'); | |
gulp.task('zip', function(){ | |
return gulp.src('recipe/*') | |
.pipe(foreach(function(stream, file){ | |
return gulp.src( | |
path.basename(file.path) + '/**/*', | |
{ cwd: 'recipe/' } | |
) | |
.pipe(zip(name + '.zip')); | |
})) | |
.pipe(gulp.dest('download/')); | |
}); |
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
var merge = require('merge-stream'); | |
var data = [{ name: 'a' }, { name: 'b' }, { name: 'c' }]; | |
gulp.task('page', function(){ | |
return merge(data.map(function(entry){ | |
return gulp.src('template.html') | |
.pipe(consolidate(entry)) | |
.pipe(gulp.dest('dist/')); | |
})); | |
}); |
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
gulp.task('async', function(){ | |
return iHaveAPromise(); | |
}); |
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
gulp.task('async', function(){ | |
var deferred = Q.defer(); | |
setTimeout(function() { | |
deferred.resolve(); | |
}, 1000); | |
return deferred.promise; | |
}); |
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
gulp.task('async', function(callback){ | |
setTimeout(function() { | |
callback(); | |
}, 1000); | |
}); |
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
var meta = require('./package.json'); | |
gulp.task('icon', function(){ | |
gulp.src('icon/*.svg') | |
.pipe(iconfont({ fontName: meta.name }) | |
.pipe(gulp.dest('dist')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment