A
A
ANDREY REBEKA2019-05-23 15:55:47
gulp.js
ANDREY REBEKA, 2019-05-23 15:55:47

Help creating a Gulp build?

I would be grateful for the help, since I myself am still a beginner in this matter.
There are the following plugins: browser-sync, gulp-sass, gulp-autoprefixer.
And the following file structure.

  • dist
  • src
    • css
    • fonts
    • img
    • js
    • sass
      • blocks
      • style.sass

    • index.html


You need to configure gulpfile.js so that when the "gulp" task is called, browser-sync is launched and monitors changes in index.html, in all js files and in all sass files, compiling the latter into a css file, automatically placing vendor prefixes and displaying changes in real time.
And when you run "gulp dist", all folders and files (except for the sass folder and its contents) are transferred to the dist folder.
Here is my gulpfile.js, tell me where and what am I doing wrong?
let gulp         = require('gulp'),
    browserSync  = require('browser-sync').create(),
    sass         = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer')

gulp.task('sass', function(done) {
    gulp.src("src/sass/**/*.sass || scss")
    .pipe(sass())
    .pipe(gulp.dest("scr/css"))
    .pipe(browserSync.stream());
    done();
});

gulp.task('serve', function(done) {

    browserSync.init({
        server: "src/"
    });

    gulp.watch("scr/sass/**/*.sass || scss", gulp.series('sass'));
    gulp.watch("scr/*.html").on('change', () => {
      browserSync.reload();
      done();
  });
    done();
});

gulp.task('dist', function(done) {
    gulp.src('src/**/*.html, .css, .js')
    .pipe(gulp.dest('dist/'))
});

gulp.task('default', gulp.series('sass', 'serve'));
gulp.task('dist', gulp.('dist'));

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question