I have this below gulpfile.js. When i run the app using 'gulp start' then it is showing start is not a function. Glup-cli version i'm using V4.0.0
const gulp = require('gulp');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
const scripts = require('./scripts');
const styles = require('./styles');
// Some pointless comments for our project.
var devMode = false;
gulp.task('css', function() {
gulp.src(styles)
.pipe(concat('main.css'))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('js', function() {
gulp.src(scripts)
.pipe(concat('scripts.js'))
.pipe(gulp.dest('./dist/js'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('html', function() {
return gulp.src('./src/templates/**/*.html')
.pipe(gulp.dest('./dist/'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('build', function() {
gulp.start(['css', 'js', 'html'])
});
gulp.task('browser-sync', function() {
browserSync.init(null, {
open: false,
server: {
baseDir: 'dist',
}
});
});
gulp.task('start', function() {
devMode = true;
gulp.start(['build', 'browser-sync']);
gulp.watch(['./src/css/**/*.css'], ['css']);
gulp.watch(['./src/js/**/*.js'], ['js']);
gulp.watch(['./src/templates/**/*.html'], ['html']);
});
gulp is a JavaScript-based build tool for automating the execution of web development tasks. Actually, gulp can automate anything that may be done from Node. js, and since Node. js can run shell commands, gulp may actually be used to automate any task.
A private task looks and acts like any other task, but an end-user can't ever execute it independently. To register a task publicly, export it from your gulpfile. const { series } = require('gulp'); // The `clean` function is not exported so it can be considered a private task.
watch() Allows watching globs and running a task when a change occurs. Tasks are handled uniformly with the rest of the task system.
gulp.start
has been deprecated in v4. Depending on your needs, you can use gulp.series
or gulp.parallel
instead.
- gulp.task('start', function() {
- devMode = true;
- gulp.start(['build', 'browser-sync']);
+ gulp.task('start', gulp.series('build', 'browser-sync'), function(done) {
+ devMode = true;
gulp.watch(['./src/css/**/*.css'], ['css']);
gulp.watch(['./src/js/**/*.js'], ['js']);
gulp.watch(['./src/templates/**/*.html'], ['html']);
});
This question is probably a duplicated of this one, but since that question hasn't got an accepted answer I'll just echo Mark's answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With