S
S
sergey199408082018-07-05 16:28:29
JavaScript
sergey19940808, 2018-07-05 16:28:29

Gulp how to do tracking js and scss files?

Hello, I have the following config:

'use strict';

const gulp =  require('gulp');
const sass = require('gulp-sass');
const babel = require('gulp-babel');


gulp.task('js', () => {
        return gulp.src('assets/js/app.js')
            .pipe(babel({
                presets: ['env']
            }))
            .pipe(gulp.dest('public'))
});

gulp.task('sass', () => {
    return gulp.src('./assets/scss/style.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./public'));
});

gulp.watch('./assets/scss/style.scss', gulp.series('sass'));
gulp.watch('./assets/js/app.js', gulp.series('js'));

I run all this in this way:
"start": "lite-server | gulp sass | gulp js"
Files are tracked and changed on the first change, but then the task works out but does not change

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Seryakov, 2018-07-05
@sergey19940808

gulp.task('watch', () => {
gulp.watch('./assets/scss/style.scss', gulp.series('sass'));
gulp.watch('./assets/js/ app.js', gulp.series('js'));
});
gulp.task(
'default',
gulp.series(
'sass',
'js',
'watch'
));
Run with gulp command

K
Kate888, 2020-03-24
@Kate888

But still does not see the styles (

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question