Skip to content

Instantly share code, notes, and snippets.

@tristolliday
Last active October 31, 2019 11:43
Show Gist options
  • Select an option

  • Save tristolliday/c620de95d73b55e33b8491b0620e13af to your computer and use it in GitHub Desktop.

Select an option

Save tristolliday/c620de95d73b55e33b8491b0620e13af to your computer and use it in GitHub Desktop.
Migrate a gulp 3 task to gulp 4
// Gulp 3 Task
var gulp = require("gulp");
var rename = require('gulp-rename');
var coreScripts = []; // your main scripts
gulp.task('scripts', function () {
return gulp.src(coreScripts)
.pipe(concat('global.js'))
.pipe(gulp.dest('blah/html/js'))
.pipe(rename('global.min.js'))
.pipe(gulp.dest('blah/html/js'))
//.pipe(browserSync.reload({
// stream: true
//}))
});
// Gulp 4 Task
const { src, dest, series, parallel } = require('gulp');
const rename = require('gulp-rename');
const coreScripts = []; // your main scripts
const scriptsTask = function () {
return src(coreScripts)
.pipe(concat('global.js'))
.pipe(dest('blah/html/js'))
.pipe(rename({ extname: '.min.js' }))
.pipe(dest('blah/html/js'));
};
exports.build = series(buildScripts, xxx, ...); // for tasks that run in series
// or
exports.build = parallel(buildScripts, xxx, ...); // for tasks that run in parallel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment