Created
August 4, 2018 12:38
-
-
Save amitasaurus/6a41cdd7f947914f5a5fe112e14c86bc to your computer and use it in GitHub Desktop.
gulp autopolyfiller sample
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 concat = require('gulp-concat'); | |
var order = require('gulp-order'); | |
var uglify = require('gulp-uglify'); | |
var autopolyfiller = require('gulp-autopolyfiller'); | |
var merge = require('event-stream').merge; | |
gulp.task('default', function () { | |
// Concat all required js files | |
var all = gulp.src('js/*.js') | |
.pipe(concat('all.js')); | |
// Generate polyfills for all files | |
var polyfills = all | |
.pipe(autopolyfiller('polyfills.js')); | |
// Merge polyfills and all files streams | |
return merge(polyfills, all) | |
// Order files. NB! polyfills MUST be first | |
.pipe(order([ | |
'polyfills.js', | |
'all.js' | |
])) | |
// Make single file | |
.pipe(concat('all.min.js')) | |
// Uglify it | |
.pipe(uglify()) | |
// And finally write `all.min.js` into `build/` dir | |
.pipe(gulp.dest('build')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment