Answer the question
In order to leave comments, you need to log in
How to run a gulp task with a parameter?
I can't figure out how to run the same task with parameters (language selection).
There is a task
// HTML
const html = (lang) => {
return gulp.src("source/*.html")
.pipe(rename({suffix: lang}))
.pipe(gulp.dest("build"));
};
exports.html = html;
// Build
const build = (done) => gulp.series(
clean,
copy,
styles,
sprite,
html(ru),
html(en),
js
)(done);
exports.build = build;
Answer the question
In order to leave comments, you need to log in
But the task didn't stop running as Starting 'anonymous'...
const html = (lang) => { // (1)
// 1 - первый вызов происходит, когда вы подключаете таску и передаете ей свои аргументы.
return () => { // (2)
// 2- эта функция возвращается после передачи аргументов
// и вызывается, когда вы таску запускаете.
// как видите, у нее нет имени.
return gulp.src("source/*.njk")
.pipe(rename({suffix: lang}))
.pipe(gulp.dest("build"));
};
}
exports.html = html;
const html = (lang) => {
// объявляем функцию
const html = () => {
return gulp.src("source/*.njk")
.pipe(rename({suffix: lang}))
.pipe(gulp.dest("build"));
};
return html;
}
exports.html = html;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question