H
H
hellcaster2018-08-15 19:20:38
Web development
hellcaster, 2018-08-15 19:20:38

What's wrong with gulpfile?

Tried to setup gulpfile today

gulpfile
var
  gulp         = require("gulp"),
  del          = require("del"),
  webp         = require("gulp-webp"),
  minify       = require("gulp-csso"),
  sass         = require("gulp-sass"),
  rename       = require("gulp-rename"),
  plumber      = require("gulp-plumber"),
  postcss      = require("gulp-postcss"),
  csscomb      = require("gulp-csscomb"),
  autoprefixer = require("autoprefixer"),
  posthtml     = require("gulp-posthtml"),
  imagemin     = require("gulp-imagemin"),
  svgstore     = require("gulp-svgstore"),
  server       = require("browser-sync").create();

gulp.task("style", function() {
  gulp.src("src/sass/style.scss")
    .pipe(plumber())
    .pipe(sass().on("error", sass.logError))
    .pipe(postcss([autoprefixer()]))
    .pipe(csscomb())
    .pipe(gulp.dest("build/css"))
    .pipe(minify())
    .pipe(rename("style.min.css"))
    .pipe(gulp.dest("build/css"))
    .pipe(server.stream());
});

gulp.task("sprite", function() {
  return gulp.src("src/img/svg/icon-*.svg")
    .pipe(svgstore({
      inlineSvg: true
    }))
    .pipe(rename("sprite.svg"))
    .pipe(gulp.dest("build/img"));
});

gulp.task("html", function() {
  return gulp.src("src/*.html")
    .pipe(posthtml([
      include()
    ]))
    .pipe(gulp.dest("build"));
});

gulp.task("images", function() {
  return gulp.src("src/img/**/*.{png,jpg,svg}")
    .pipe(imagemin([imagemin.optipng({ optimizationLevel: 3 }),
      imagemin.jpegtran({ progressive: true }),
      imagemin.svgo()
    ]))
    .pipe(gulp.dest("src/img"))
});

gulp.task("webp", function() {
  return gulp.src("src/img/**/*.{png,jpg}")
    .pipe(webp({ quality: 90 }))
    .pipe(gulp.dest("src/img"))
});

gulp.task("clean", function() {
  return del("build");
});

gulp.task("copy", function() {
  return gulp.src([
      "src/fonts/**/*.{woff,woff2}",
      "src/img/**",
      "src/js/**"
    ], {
      base: "src"
    })
    .pipe(gulp.dest("build"));
});

gulp.task("serve", function() {
  server.init({
    server: "build/"
  });

  gulp.watch("src/sass/**/*.scss", ["style"]);
  gulp.watch("src/*.html", ["html"]);
  gulp.watch("src/js/*.js").on("change", server.reload);
});

gulp.task("build", function(done) {
  run(
    "clean",
    "copy",
    "style",
    "sprite",
    "html",
    done
  );
});


but when I run it, I get an error
Mistake
5b74525ec770c353638977.png

What's wrong with the run command? Help me please
package.json
"scripts": {
    "test": "npm run style",
    "build": "gulp build",
    "start": "npm run build && gulp serve"
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dymok, 2018-08-15
@web_Developer_Victor

What if we change the build task to the following?

gulp.task('build',['clean', 'copy', 'style', 'sprite', 'html']);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question