A
A
Andrej Sharapov2019-07-10 17:05:58
JavaScript
Andrej Sharapov, 2019-07-10 17:05:58

What is the jamb of task processing?

Hello!
I have another question about setting up tasks ... Such a thing, I don’t understand what the problem is.
Foreword:
1. I work in Vizhla, using Live Server and Live Sass Compiler
2. set up a hapfile, connected tasks for PUG, SASS, JS:

spoiler

gulp.task('pug', function buildHTML() {
    return gulp.src('build/pug/pages/*.pug')
        .pipe(pug({pretty: true}))
        .pipe(gulp.dest('.'))
});

gulp.task('sass', () => {
    return gulp.src(['global.css', 'aside.css'].map(file => `build/css/${file}`))
        .pipe(sourcemaps.init())
        .pipe(concat('style.css'))
        .pipe(mmq({log: true}))
        .pipe(cleanCSS()) //- minify css
        .pipe(rename({suffix: ".min"}))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('css'))
});

gulp.task('scripts', () => {
    return gulp.src('build/js/*.js')
        .pipe(sourcemaps.init())
        .pipe(babel({presets: ['@babel/preset-env']}))
        .pipe(concat('scripts.js'))
        .pipe(uglify()) //- minify js
        .pipe(rename({suffix: ".min"}))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('js'))
});


They work fine. Then, connected tracking:
gulp.task('component-assembly', function () {
    gulp.watch('build/pug/pages/*.pug'), gulp.series('pug');
    gulp.watch('build/css/*.css'), gulp.series('sass');
    gulp.watch('build/js/*.js',  gulp.series('scripts'));
});

gulp.task('watch', gulp.parallel('pug', 'sass', 'scripts', 'component-assembly'));

Here problems begin:
I launch in the terminal gulp watch- the task works, but does not process as it is necessary. Rather, it starts and even the "first phase" works, but nothing happens with subsequent changes in the files. Those. The task seems to hang, although the tracking continues in the terminal.
> watch: Finished 'pug' after 934 ms
> watch: Finished 'scripts' after 1.08 s
> watch: Finished 'sass' after 1.12 s

After the new changes, you have to:
1. cut off the terminal and start it again
2. in VSCode, through the Gulp Tasks plugin, press Restart
Tell me, what's the problem? Maybe the task is not set up correctly, maybe it's just that the vizhla slows down or something else?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2019-07-10
@Madeas

gulp.serial(
  gulp.parallel('pug', 'sass', 'scripts'), 
  'component-assembly'
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question