teambition / gulp-sequence Goto Github PK
View Code? Open in Web Editor NEWRun a series of gulp tasks in order
License: MIT License
Run a series of gulp tasks in order
License: MIT License
Hi,
I create some dynamic task, and i want to pass to gulp-sequence.
But i don't want to run it in parallel.
Here a example
var tinypng_task = [];
banners.forEach(function(key) {
gulp.task('tinypng:' + key, function() { return task.tinypng(key, 'params')});
tinypng_task.push('tinypng:' + key)
});
After that, i call gulp-sequence
modules.gulp.task('default', modules.sequence(tinypng_task));
How can i run it like
modules.gulp.task('default', modules.sequence('tinypng_task:key1', 'tinypng_task:key2', 'etc...'));
Need some help :)
Thanks !
I saw this being used in https://github.com/vigetlabs/gulp-starter and was wondering what differences there are between this repo and https://github.com/OverZealous/run-sequence ? Looks like you both released them at roughly the same time. Thanks for your input :)
"use strict";
const gulp = require("gulp"),
newer = require("gulp-newer"),
imagemin = require("gulp-imagemin"),
sass = require("gulp-sass"),
sourcemaps = require("gulp-sourcemaps"),
autoprefixer = require("gulp-autoprefixer"),
cleanCSS = require('gulp-clean-css'),
rename = require("gulp-rename"),
concat = require("gulp-concat"),
uglify = require("gulp-uglify"),
gutil = require("gulp-util"),
lodash = require("lodash"),
gulpSequence = require("gulp-sequence"),
browsersync = require("browser-sync"),
fileinclude = require('gulp-file-include');
const folder = {
src: "src/", // source files
dist: "dist/", // build files
dist_assets: "dist/assets/" //build assets files
};
/*
Copy assets/vendors from their node_module package to scss & js folder
Read More: https://florian.ec/articles/frontend-dependencies-npm/
*/
gulp.task("copy-assets", function () {
var assets = {
js: [
"./node_modules/jquery/dist/jquery.js",
"./node_modules/bootstrap/dist/js/bootstrap.bundle.js",
"./node_modules/metismenu/dist/metisMenu.js",
"./node_modules/jquery-slimscroll/jquery.slimscroll.js",
"./node_modules/node-waves/dist/waves.js",
"./node_modules/waypoints/lib/jquery.waypoints.min.js",
"./node_modules/jquery.counterup/jquery.counterup.min.js"
],
scss: [],
};
var third_party_assets = {
css_js: [
// {"name": "bootstrap-select", "assets": ["./node_modules/bootstrap-select/dist/js/bootstrap-select.min.js", "./node_modules/bootstrap-select/dist/css/bootstrap-select.min.css"]},
{"name": "autocomplete", "assets": ["./node_modules/devbridge-autocomplete/dist/jquery.autocomplete.min.js"]},
{"name": "autonumeric", "assets": ["./node_modules/autonumeric/autoNumeric-min.js"]},
{"name": "bootstrap-tagsinput", "assets": ["./node_modules/@adactive/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js", "./node_modules/@adactive/bootstrap-tagsinput/dist/bootstrap-tagsinput.css"]},
{"name": "bootstrap-datepicker", "assets": ["./node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js","./node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css"]},
{"name": "bootstrap-filestyle2", "assets": ["./node_modules/bootstrap-filestyle2/src/bootstrap-filestyle.min.js"]},
{"name": "bootstrap-tagsinput", "assets": ["./node_modules/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js","./node_modules/bootstrap-tagsinput/dist/bootstrap-tagsinput.css"]},
{"name": "bootstrap-timepicker", "assets": ["./node_modules/bootstrap-timepicker/js/bootstrap-timepicker.min.js", "./node_modules/bootstrap-timepicker/css/bootstrap-timepicker.min.css"] },
{"name": "bootstrap-daterangepicker", "assets": ["./node_modules/bootstrap-daterangepicker/daterangepicker.js", "./node_modules/bootstrap-daterangepicker/daterangepicker.css"] },
{"name": "bootstrap-select", "assets": ["./node_modules/bootstrap-select/dist/js/bootstrap-select.min.js", "./node_modules/bootstrap-select/dist/css/bootstrap-select.min.css"]},
{"name": "bootstrap-colorpicker", "assets": ["./node_modules/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js", "./node_modules/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css"]},
{"name": "bootstrap-touchspin", "assets": ["./node_modules/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js", "./node_modules/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.css"] },
{"name": "bootstrap-maxlength", "assets": ["./node_modules/bootstrap-maxlength/bootstrap-maxlength.min.js"]},
{"name": "chart-js", "assets": ["./node_modules/chart.js/dist/Chart.bundle.min.js"]},
{"name":"chartist", "assets": ["./node_modules/chartist/dist/chartist.min.js", "./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.min.js", "./node_modules/chartist/dist/chartist.min.css"] },
{"name": "c3", "assets": ["./node_modules/c3/c3.min.js", "./node_modules/c3/c3.min.css"]},
{"name": "d3", "assets": ["./node_modules/d3/dist/d3.min.js"]},
{"name": "custombox", "assets": ["./node_modules/custombox/dist/custombox.min.js", "./node_modules/custombox/dist/custombox.min.css"]},
{
"name": "datatables", "assets": ["./node_modules/datatables.net/js/jquery.dataTables.min.js",
"./node_modules/datatables.net-bs4/js/dataTables.bootstrap4.min.js",
"./node_modules/datatables.net-responsive/js/dataTables.responsive.min.js",
"./node_modules/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js",
"./node_modules/datatables.net-buttons/js/dataTables.buttons.min.js",
"./node_modules/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js",
"./node_modules/datatables.net-buttons/js/buttons.html5.min.js",
"./node_modules/datatables.net-buttons/js/buttons.flash.min.js",
"./node_modules/datatables.net-buttons/js/buttons.colVis.js",
"./node_modules/datatables.net-buttons/js/buttons.print.min.js",
"./node_modules/datatables.net-select/js/dataTables.select.min.js",
"./node_modules/datatables.net-keytable/js/dataTables.keyTable.min.js",
"./node_modules/datatables.net-bs4/css/dataTables.bootstrap4.css",
"./node_modules/datatables.net-responsive-bs4/css/responsive.bootstrap4.css",
"./node_modules/datatables.net-buttons-bs4/css/buttons.bootstrap4.css",
"./node_modules/datatables.net-select-bs4/css/select.bootstrap4.css"]
},
{"name": "clockpicker", "assets": ["./node_modules/clockpicker/dist/bootstrap-clockpicker.min.js", "./node_modules/clockpicker/dist/bootstrap-clockpicker.min.css"]},
{"name": "echarts", "assets": ["./node_modules/echarts/dist/echarts.min.js"]},
{"name": "ion-rangeslider", "assets": ["./node_modules/ion-rangeslider/js/ion.rangeSlider.min.js", "./node_modules/ion-rangeslider/css/ion.rangeSlider.css"]},
{"name": "footable", "assets": ["./node_modules/footable/dist/footable.all.min.js", "./node_modules/footable/css/footable.core.min.css"]},
{"name": "flot-charts", "assets": ["./node_modules/flot-charts/jquery.flot.js",
"./node_modules/flot-charts/jquery.flot.time.js",
"./node_modules/flot-charts/jquery.flot.resize.js",
"./node_modules/flot-charts/jquery.flot.pie.js",
"./node_modules/flot-charts/jquery.flot.selection.js",
"./node_modules/flot-charts/jquery.flot.stack.js",
"./node_modules/flot-charts/jquery.flot.crosshair.js",
"./node_modules/flot.curvedlines/curvedLines.js",
"./node_modules/flot-axislabels/jquery.flot.axislabels.js",
"./node_modules/jquery.flot.tooltip/js/jquery.flot.tooltip.min.js",
"./node_modules/flot-orderbars/js/jquery.flot.orderBars.js"]
},
{"name": "fullcalendar", "assets": ["./node_modules/fullcalendar/dist/fullcalendar.min.js", "./node_modules/fullcalendar/dist/fullcalendar.min.css"]},
{"name": "tooltipster", "assets": ["./node_modules/tooltipster/dist/js/tooltipster.bundle.min.js", "./node_modules/tooltipster/dist/css/tooltipster.bundle.min.css"]},
{"name": "jquery-ui", "assets": ["./node_modules/jquery-ui/jquery-ui.min.js"]},
{"name": "jszip", "assets": ["./node_modules/jszip/dist/jszip.min.js"]},
{"name": "jquery-knob", "assets": ["./node_modules/jquery-knob/dist/jquery.knob.min.js"]},
{"name": "jquery-mask-plugin", "assets": ["./node_modules/jquery-mask-plugin/dist/jquery.mask.min.js"]},
{"name": "justgage", "assets": ["./node_modules/justgage/justgage.js"]},
{"name": "jquery-toast", "assets": ["./node_modules/jquery-toast-plugin/dist/jquery.toast.min.js", "./node_modules/jquery-toast-plugin/dist/jquery.toast.min.css"]},
{"name": "jquery-sparkline", "assets": ["./node_modules/jquery-sparkline/jquery.sparkline.min.js"]},
{"name": "jquery-countdown", "assets": ["./node_modules/jquery-countdown/dist/jquery.countdown.min.js"]},
{"name": "jquery-mockjax", "assets": ["./node_modules/jquery-mockjax/dist/jquery.mockjax.min.js"]},
{"name": "jquery-tabledit", "assets": ["./node_modules/jquery-tabledit/jquery.tabledit.min.js"]},
{"name": "gmaps", "assets": ["./node_modules/gmaps/gmaps.min.js"]},
{
"name": "jquery-vectormap", "assets": ["./node_modules/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.min.js",
"./node_modules/admin-resources/jquery.vectormap/maps/jquery-jvectormap-world-mill-en.js",
"./node_modules/admin-resources/jquery.vectormap/maps/jquery-jvectormap-us-merc-en.js",
"./node_modules/admin-resources/jquery.vectormap/maps/jquery-jvectormap-au-mill-en.js",
"./node_modules/admin-resources/jquery.vectormap/maps/jquery-jvectormap-us-il-chicago-mill-en.js",
"./node_modules/admin-resources/jquery.vectormap/maps/jquery-jvectormap-in-mill-en.js",
"./node_modules/admin-resources/jquery.vectormap/maps/jquery-jvectormap-uk-mill-en.js",
"./node_modules/admin-resources/jquery.vectormap/maps/jquery-jvectormap-ca-lcc-en.js",
"./node_modules/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css"]
},
{
"name": "jquery-mapael", "assets": ["./node_modules/jquery-mapael/js/jquery.mapael.min.js",
"./node_modules/jquery-mapael/js/maps/world_countries.min.js",
"./node_modules/jquery-mapael/js/maps/usa_states.min.js"]
},
{"name": "dropzone", "assets": ["./node_modules/dropzone/dist/min/dropzone.min.js", "./node_modules/dropzone/dist/min/dropzone.min.css"]},
{"name": "katex", "assets": ["./node_modules/katex/dist/katex.min.js"]},
{"name": "moment", "assets": ["./node_modules/moment/min/moment.min.js"]},
{"name": "morris-js", "assets": ["./node_modules/morris.js/morris.min.js"]},
{"name": "nestable2", "assets": ["./node_modules/nestable2/dist/jquery.nestable.min.js", "./node_modules/nestable2/dist/jquery.nestable.min.css"]},
{"name": "raphael", "assets": ["./node_modules/raphael/raphael.min.js"]},
{"name": "ratings", "assets": ["./node_modules/admin-resources/ratings/jquery.raty-fa.js"]},
{"name": "pdfmake", "assets": ["./node_modules/pdfmake/build/pdfmake.min.js", "./node_modules/pdfmake/build/vfs_fonts.js"]},
{"name": "stepy", "assets": ["./node_modules/stepy/lib/jquery.stepy.js", "./node_modules/stepy/lib/jquery.stepy.css"]},
{"name": "lightbox2", "assets": ["./node_modules/lightbox2/dist/js/lightbox.min.js", "./node_modules/lightbox2/dist/css/lightbox.min.css"]},
{"name": "spinkit", "assets": ["./node_modules/spinkit/css/spinkit.css"]},
{"name": "switchery", "assets": ["./node_modules/mohithg-switchery/dist/switchery.min.js", "./node_modules/mohithg-switchery/dist/switchery.min.css"]},
{"name": "parsleyjs", "assets": ["./node_modules/parsleyjs/dist/parsley.min.js"]},
{"name": "sweetalert2", "assets": ["./node_modules/sweetalert2/dist/sweetalert2.min.js", "./node_modules/sweetalert2/dist/sweetalert2.min.css"]},
{"name": "summernote", "assets": ["./node_modules/summernote/dist/summernote-bs4.min.js", "./node_modules/summernote/dist/summernote-bs4.css"]},
{"name": "select2", "assets": ["./node_modules/select2/dist/js/select2.min.js", "./node_modules/select2/dist/css/select2.min.css"]},
{"name": "slick-slider", "assets": ["./node_modules/slick-slider/slick/slick.min.js", "./node_modules/slick-slider/slick/slick.css", "./node_modules/slick-slider/slick/slick-theme.css",]},
{"name": "rwd-table", "assets": ["./node_modules/admin-resources/rwd-table/rwd-table.min.js", "./node_modules/admin-resources/rwd-table/rwd-table.min.css"]},
{"name": "treeview", "assets": ["./node_modules/jstree/dist/jstree.min.js","./node_modules/jstree/dist/themes/default/style.css"]},
{"name": "tablesaw", "assets": ["./node_modules/tablesaw/dist/tablesaw.js", "./node_modules/tablesaw/dist/tablesaw.css"]},
{"name": "typeahead", "assets": ["./node_modules/typeahead.js/dist/typeahead.bundle.min.js"]},
{"name": "handlebars", "assets": ["./node_modules/handlebars/dist/handlebars.min.js"]},
{
"name": "quill", "assets": ["./node_modules/quill/dist/quill.min.js", "./node_modules/quill/dist/quill.core.css",
"./node_modules/quill/dist/quill.bubble.css",
"./node_modules/quill/dist/quill.snow.css"]
},
{"name": "x-editable", "assets": ["./node_modules/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.min.js", "./node_modules/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css"]},
]
};
//copying third party assets
lodash(third_party_assets).forEach(function (assets, type) {
if (type == "css_js") {
lodash(assets).forEach(function (plugin) {
var name = plugin['name'];
var assetlist = plugin['assets'];
lodash(assetlist).forEach(function (asset) {
gulp.src(asset).pipe(gulp.dest(folder.dist_assets + "libs/" + name));
});
});
//gulp.src(assets).pipe(gulp.dest(folder.dist_assets + "css/vendor"));
}
});
//copying required assets
lodash(assets).forEach(function (assets, type) {
if (type == "scss") {
gulp
.src(assets)
.pipe(
rename({
// rename aaa.css to _aaa.scss
prefix: "_",
extname: ".scss"
})
)
.pipe(gulp.dest(folder.src + "scss/vendor"));
} else {
gulp.src(assets).pipe(gulp.dest(folder.src + "js/vendor"));
}
});
//copying data files
gulp.src(folder.src + "data/**").pipe(gulp.dest(folder.dist_assets + "/data"));
});
// image processing
gulp.task("imageMin", function () {
var out = folder.dist_assets + "images";
return gulp
.src(folder.src + "images/**/*")
.pipe(newer(out))
.pipe(imagemin())
.pipe(gulp.dest(out));
});
// copy fonts
// copy fonts from src folder to dist folder
gulp.task("fonts", function () {
var out = folder.dist_assets + "fonts/";
return gulp.src([folder.src + "fonts/**/*"]).pipe(gulp.dest(out));
});
// copy html
// copy html files from src folder to dist folder, also copy favicons
gulp.task("html", function () {
var out = folder.dist;
return gulp
.src([
folder.src + "html/*.html",
folder.src + "html/*.ico", // favicons
folder.src + "html/*.png"
])
.pipe(fileinclude({
prefix: '@@',
basepath: '@file',
indent: true
}))
.pipe(gulp.dest(out));
});
// compile & minify sass
gulp.task("css", function () {
gulp
.src([folder.src + "/scss/bootstrap.scss"])
.pipe(sourcemaps.init())
.pipe(sass()) // scss to css
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(gulp.dest(folder.dist_assets + "css/"))
.pipe(cleanCSS())
.pipe(
rename({
// rename app.css to icons.min.css
suffix: ".min"
})
)
.pipe(sourcemaps.write("./")) // source maps for icons.min.css
.pipe(gulp.dest(folder.dist_assets + "css/"));
gulp
.src([folder.src + "/scss/bootstrap-dark.scss"])
.pipe(sourcemaps.init())
.pipe(sass()) // scss to css
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(gulp.dest(folder.dist_assets + "css/"))
.pipe(cleanCSS())
.pipe(
rename({
// rename app.css to icons.min.css
suffix: ".min"
})
)
.pipe(sourcemaps.write("./")) // source maps for icons.min.css
.pipe(gulp.dest(folder.dist_assets + "css/"));
gulp
.src([folder.src + "/scss/icons.scss"])
.pipe(sourcemaps.init())
.pipe(sass()) // scss to css
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(gulp.dest(folder.dist_assets + "css/"))
.pipe(cleanCSS())
.pipe(
rename({
// rename app.css to icons.min.css
suffix: ".min"
})
)
.pipe(sourcemaps.write("./")) // source maps for icons.min.css
.pipe(gulp.dest(folder.dist_assets + "css/"));
gulp
.src([folder.src + "/scss/app-dark.scss"])
.pipe(sourcemaps.init())
.pipe(sass()) // scss to css
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(gulp.dest(folder.dist_assets + "css/"))
.pipe(cleanCSS())
.pipe(
rename({
// rename app.css to app.min.css
suffix: ".min"
})
)
.pipe(sourcemaps.write("./")) // source maps for app.min.css
.pipe(gulp.dest(folder.dist_assets + "css/"));
gulp
.src([folder.src + "/scss/app-rtl.scss"])
.pipe(sourcemaps.init())
.pipe(sass()) // scss to css
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(gulp.dest(folder.dist_assets + "css/"))
.pipe(cleanCSS())
.pipe(
rename({
// rename app.css to app.min.css
suffix: ".min"
})
)
.pipe(sourcemaps.write("./")) // source maps for app.min.css
.pipe(gulp.dest(folder.dist_assets + "css/"));
gulp
.src([folder.src + "/scss/app-dark-rtl.scss"])
.pipe(sourcemaps.init())
.pipe(sass()) // scss to css
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(gulp.dest(folder.dist_assets + "css/"))
.pipe(cleanCSS())
.pipe(
rename({
// rename app.css to app.min.css
suffix: ".min"
})
)
.pipe(sourcemaps.write("./")) // source maps for app.min.css
.pipe(gulp.dest(folder.dist_assets + "css/"));
return gulp
.src([folder.src + "/scss/app.scss"])
.pipe(sourcemaps.init())
.pipe(sass()) // scss to css
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(gulp.dest(folder.dist_assets + "css/"))
.pipe(cleanCSS())
.pipe(
rename({
// rename app.css to app.min.css
suffix: ".min"
})
)
.pipe(sourcemaps.write("./")) // source maps for app.min.css
.pipe(gulp.dest(folder.dist_assets + "css/"));
});
// js
gulp.task("javascript", function () {
var out = folder.dist_assets + "js/";
//copying demo pages related assets
var app_pages_assets = {
js: [
folder.src + "js/pages/dashboard.init.js",
folder.src + "js/pages/dashboard-2.init.js",
folder.src + "js/pages/toastr.init.js",
folder.src + "js/pages/tooltipster.init.js",
folder.src + "js/pages/sweet-alerts.init.js",
folder.src + "js/pages/nestable.init.js",
folder.src + "js/pages/range-sliders.init.js",
folder.src + "js/pages/rating.init.js",
folder.src + "js/pages/scrollbar.init.js",
folder.src + "js/pages/slick-slider.init.js",
folder.src + "js/pages/treeview.init.js",
folder.src + "js/pages/calendar.init.js",
folder.src + "js/pages/taskboard.init.js",
folder.src + "js/pages/tickets.init.js",
folder.src + "js/pages/datatables.init.js",
folder.src + "js/pages/foo-tables.init.js",
folder.src + "js/pages/responsive-table.init.js",
folder.src + "js/pages/tablesaw.init.js",
folder.src + "js/pages/tabledit.init.js",
folder.src + "js/pages/jquery.todo.js",
folder.src + "js/pages/form-advanced.init.js",
folder.src + "js/pages/form-validation.init.js",
folder.src + "js/pages/form-pickers.init.js",
folder.src + "js/pages/flot.init.js",
folder.src + "js/pages/morris.init.js",
folder.src + "js/pages/google-charts.init.js",
folder.src + "js/pages/chartist.init.js",
folder.src + "js/pages/chartjs.init.js",
folder.src + "js/pages/c3.init.js",
folder.src + "js/pages/sparkline.init.js",
folder.src + "js/pages/companies.init.js",
folder.src + "js/pages/profile.init.js",
folder.src + "js/pages/coming-soon.init.js",
folder.src + "js/pages/echart.init.js",
folder.src + "js/pages/email-read.init.js",
folder.src + "js/pages/email-compose.init.js",
folder.src + "js/pages/wizard.init.js",
folder.src + "js/pages/form-masks.init.js",
folder.src + "js/pages/form-summernote.init.js",
folder.src + "js/pages/form-quilljs.init.js",
folder.src + "js/pages/form-xeditable.init.js",
folder.src + "js/pages/typehead.init.js",
folder.src + "js/pages/gmaps.init.js",
folder.src + "js/pages/jvectormap.init.js",
folder.src + "js/pages/mapael-map.init.js",
]
};
lodash(app_pages_assets).forEach(function (assets, type) {
gulp.src(assets)
.pipe(uglify())
.on("error", function (err) {
gutil.log(gutil.colors.red("[Error]"), err.toString());
})
.pipe(gulp.dest(out + "pages"));
});
// It's important to keep files at this order
// so that `app.min.js` can be executed properly
gulp
.src([
folder.src + "js/vendor/jquery.js",
folder.src + "js/vendor/bootstrap.bundle.js",
folder.src + "js/vendor/jquery.slimscroll.js",
folder.src + "js/vendor/metisMenu.js",
folder.src + "js/vendor/waves.js",
folder.src + "js/vendor/jquery.waypoints.min.js",
folder.src + "js/vendor/jquery.counterup.min.js"
])
.pipe(sourcemaps.init())
.pipe(concat("vendor.js"))
.pipe(gulp.dest(out))
.pipe(
rename({
// rename app.js to app.min.js
suffix: ".min"
})
)
.pipe(uglify())
.on("error", function (err) {
gutil.log(gutil.colors.red("[Error]"), err.toString());
})
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest(out));
return gulp
.src([
folder.src + "js/app.js"
])
.pipe(sourcemaps.init())
.pipe(concat("app.js"))
.pipe(gulp.dest(out))
.pipe(
rename({
// rename app.js to app.min.js
suffix: ".min"
})
)
.pipe(uglify())
.on("error", function (err) {
gutil.log(gutil.colors.red("[Error]"), err.toString());
})
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest(out));
});
// live browser loading
gulp.task("browserSync", function () {
browsersync.init({
server: {
baseDir: folder.dist
}
});
});
// watch all changes
gulp.task("watch", function () {
gulp.watch(folder.src + "html/", ["html", browsersync.reload]);
gulp.watch(folder.src + "assets/images//", [
"imageMin",
browsersync.reload
]);
gulp.watch(folder.src + "assets/fonts/**/", ["fonts", browsersync.reload]);
gulp.watch(folder.src + "scss//*", ["css", browsersync.reload]);
gulp.watch(folder.src + "js//*", ["javascript", browsersync.reload]);
});
// default task
gulp.task(
"default",
gulpSequence(
"copy-assets",
"html",
"imageMin",
"fonts",
"css",
"javascript",
"browserSync",
"watch"
)
);
// build
gulp.task(
"build",
gulpSequence("copy-assets", "html", "imageMin", "fonts", "css", "javascript")
);
im using gulp v4.0.0 i need it to connect the project to mysql database i cant do that with a lower version
I've been running into an issue where the plugin occasionally throws a "thunk already filled error". I think it usually happens the second subsequent time its run during a watch, not the first.
Here's my code:
gulp.task('viewSeq', gulpSequence('copyViews', ['createTmplCache', 'cleanScripts'], 'scripts'));
gulp.task('watch', function() {
livereload.listen();
gulp.watch(srcPaths.views, ['viewSeq']);
});
And here's the stacktrace:
Error: The thunk already filled
at child (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp-sequence/node_modules/thunks/thunks.js:217:32)
at Gulp.<anonymous> (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp-sequence/node_modules/thunks/thunks.js:212:14)
at module.exports (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
at Gulp.<anonymous> (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp/index.js:36:18)
at Gaze.<anonymous> (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/index.js:18:14)
at Gaze.emit (events.js:98:17)
at Gaze.emit (/Users/cameronnokes/Repositories/detectiveui-temp/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:129:32)
I tried googling it and nothing turned up. Is there something about my setup or syntax that's wrong? Let me know if you need more details.
Hi, I have the following pretty standard setup. Somehow, gulp-sequence is not working as expected. It seems that the clean:all
process gets already the finished information even though the OS is still deleting files and has not yet finished it. (By the way, I am running Windows 7). As a consequence, I get errors later on `"no such file or directory". The following tasks are trying to write to a directory which the OS has in the meantime deleted. When I run the tasks manually after each other, everything works as expected. Thanks.
var config = require('../config')
var gulp = require('gulp');
var gulpSequence = require('gulp-sequence').use(gulp);
var del = require('del');
gulp.task('new', function(callback) {
gulpSequence(['clean:all'], ['favicons:all', 'images', 'fonts', 'site', 'sass', 'javascript', 'metalsmith'], 'watch')(callback);
});
gulp.task('clean:all', function() {
del(config.delete.build);
del(config.delete.deploy);
});
gulp-util
has been recently deprecated. Continuing to use this dependency may prevent the use of your library with the latest release of Gulp 4 so it is important to replace gulp-util
.
The README.md lists alternatives for all the components so a simple replacement should be enough.
Your package is one of the most popular packages still relying on gulp-util
, it would be good to publish a fixed version to npm as soon as possible.
See:
With this gulpfile.js:
var gulp = require('gulp');
var sequence = require('gulp-sequence');
require('file-manifest').generate('./gulp', ['*.js', '!config.js']);
gulp.task('travis', sequence(['lint', 'cover', 'phantom'], 'codeclimate'));
gulp.task('test', ['cover', 'browser']);
gulp.task('default', ['lint', 'test']);
gulp.task('build', sequence('clean:dist', ['copy', 'uglify']));
in 0.4.1, gulp build
produces this:
In 0.4.2, it produces this:
For what it's worth, some tasks do work. Running clean:dist
directly works in both.
I have a task like below, which includes working tasks:
gulp.task('deploy', gulpSequence(
'task-9',
[
'task-1',
'task-2',
'task-3',
'task-4',
'task-5',
'task-6',
],
'task-11'
))
I tried all three use cases, but no luck. Below lines are error logs:
[16:10:44] TypeError: gulp.on(...).on(...).on(...).on(...).start is not a function
at /home/my-project/node_modules/gulp-sequence/index.js:68:12
at apply (/home/my-project/node_modules/thunks/index.js:354:38)
at tryRun (/home/my-project/node_modules/thunks/index.js:224:19)
at runThunk (/home/my-project/node_modules/thunks/index.js:217:15)
at /home/my-project/node_modules/thunks/index.js:314:49
at apply (/home/my-project/node_modules/thunks/index.js:354:38)
at tryRun (/home/my-project/node_modules/thunks/index.js:224:19)
at runThunk (/home/my-project/node_modules/thunks/index.js:217:15)
at continuation (/home/my-project/node_modules/thunks/index.js:164:10)
at child (/home/my-project/node_modules/thunks/index.js:155:24)
I could not understand the issue. Any idea ?
Hi,
I want to push one task to gulp sequence dynamically. How can I do this?
WIN10下跑正常, 在同事的MACOS下跑报错:
function swallowError(error) {
console.error(error.toString())
this.emit('end')
}
// 将公用变量和公用函数文件转移到.tmp/less文件夹
gulp.task('moveDefineCSS', () => {
return gulp.src([ 'resources/css/define/**/*.less' ])
.pipe(gulp.dest('.tmp/less'))
})
gulp.task('css', gulpSequence(['moveDefineCSS']), () => {
let filename = []
// 转换less
gulp.src([ 'resources/css/**/*.less', '!resources/css/define/**/*.less' ])
.pipe(through.obj(function(file, enc, callback) {
filename.push(file.relative)
// less文件引入公用变量和公用函数
file.contents = Buffer.from(
'@import "variable.less";\n'
+ '@import "mixins.less";\n\n'
+ file.contents.toString()
)
this.push(file)
callback()
}))
.pipe(gulp.dest('.tmp/less'))
.pipe($.less())
// .pipe($.replace(/font-size:\s*(\d*)px;/ig, function (match, group, offset, filecontent) {
// let result = match + (group === minFontSize ? '' : `font-size:${group/minFontSize}rem;`)
// return result
// }))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe($.cssnano())
.pipe(gulp.dest('dist/css'))
// pack
return gulp.src([ 'resources/css/**/*.css', '!resources/css/nano/*.css' ])
.pipe($.newer('.tmp/css'))
.pipe($.sourcemaps.init())
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
// .pipe($.if('*.css', $.cssnano()))
.pipe($.size({ title: 'css' }))
.pipe($.sourcemaps.write('./'))
.on('error', swallowError)
.pipe(gulp.dest('dist/css'))
})
Given:
gulp.task("fileChanged", function()
{
// Try to access a non-existent object "event"
webpack.watch(event.path, webpackOptions,
{
base: path.resolve(event.path)
}, function(err, stats)
{
// ...
});
}
gulp.task("watch", ["browser-sync"], function()
{
gulp.watch(buildConfig.srcDir + "**/*.js", ["javascript"]).on("change", sequence("fileChanged"));
gulp.watch(buildConfig.srcDir + "**/*.scss").on("change", sequence("fileChanged", "css"));
});
gulp.task("default", ["watch"]);
I am getting:
[14:20:35] ReferenceError: event is not defined
at Gulp.<anonymous> (d:\Users\Gili\Documents\realestate\frontend\Gulpfile.js:94:16)
at module.exports (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\index.js:134:8)
at d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\index.js:63:12
at tryRun (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\node_modules\thunks\thunks.js:63:22)
at runThunk (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\node_modules\thunks\thunks.js:84:11)
at d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\node_modules\thunks\thunks.js:147:49
at tryRun (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\node_modules\thunks\thunks.js:63:22)
d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\node_modules\thunks\thunks.js:47
throw err;
^
TypeError: Object #<Object> has no method 'apply'
at tryRun (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\node_modules\thunks\thunks.js:63:22)
at callback (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\node_modules\thunks\thunks.js:191:24)
at next (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\node_modules\thunks\thunks.js:150:33)
at Gulp.errorListener (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp-sequence\index.js:48:11)
at Gulp.emit (events.js:117:20)
at Gulp.Orchestrator._emitTaskDone (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\index.js:264:8)
at d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\index.js:275:23
at finish (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:21:8)
at module.exports (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:36:10)
at Gulp.Orchestrator._runTask (d:\Users\Gili\Documents\realestate\frontend\node_modules\gulp\node_modules\orchestrator\index.js:273:3)
It looks like https://github.com/teambition/gulp-sequence/blob/master/index.js#L48 does not contain the kind of value you expect.
I have a watch task that includes the following:
gulp.watch('./app/**/*.js', ['lint', 'test']);
When I change it to:
gulp.watch('./app/**/*.js', gulpSequence('lint', 'test'));
The lint
and test
tasks don't appear to run at all on file changes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.