Задать вопрос
@Svyat-hulek
человек

Сборка gulp не продолжает работать после ошибки, как исправить?

Как я понял тут что то не так с .pipe(plumber()).
"use strict"


const { src, dest } = require("gulp");
const gulp = require("gulp");
const autoprefixer = require("gulp-autoprefixer");
const rigger = require("gulp-rigger");
const imagemin = require("gulp-imagemin");
const cssbeautify = require("gulp-cssbeautify");
const removeComments = require("gulp-strip-css-comments");
const rename = require("gulp-rename");
const sass = require("gulp-sass")(require('sass'));
const cssnano = require("gulp-cssnano");
const uglify = require("gulp-uglify");
const plumber = require("gulp-plumber");
const panini = require("panini");
const del = require("del");
const browserSync = require("browser-sync").create();

/* Paths */
const srcPath = "src/"
const distPath = "dist/"

const path = {
   build: {
      html: distPath,
      css: distPath + "assets/css/",
      js: distPath + "assets/js/",
      images: distPath + "assets/fonts/"
   },
   src: {
      html: srcPath + "*.html",
      css: srcPath + "assets/scss/*.scss",
      js: srcPath + "assets/js/*.js",
      images: srcPath + "assets/images/**/*.{jpg,png,svg,gif,ico,webp,webmanifest,xml,json}",
      fonts: srcPath + "assets/fonts/**/*.{woff,woff2,eot,ttf,svg}"
   },
   watch: {
      html: srcPath + "*.html",
      css: srcPath + "assets/scss/*.scss",
      js: srcPath + "assets/js/*.js",
      images: srcPath + "assets/images/**/*.{jpg,png,svg,gif,ico,webp,webmanifest,xml,json}",
      fonts: srcPath + "assets/fonts/**/*.{woff,woff2,eot,ttf,svg}"
   },
   clean: "./" + distPath
}


function serve(done) {
   browserSync.init({
      server: {
         baseDir: "./" + distPath
      },
      notify: false, // Добавить эту опцию для отключения уведомлений об ошибках
      errorHandler: function (err) {
         console.error(err); // Вывод ошибок в консоль
         done(); // Продолжить выполнение задачи
      }
   });
}

function html() {
   return src(path.src.html, { base: srcPath })
      .pipe(plumber())
      .pipe(dest(path.build.html))
      .pipe(browserSync.reload({ stream: true }));
}

function css() {
   return src(path.src.css, { base: srcPath + "assets/scss/" })
      .pipe(plumber())
      .pipe(sass())
      .pipe(autoprefixer())
      .pipe(cssbeautify())
      .pipe(dest(path.build.css))
      .pipe(cssnano({
         zindex: false,
         discardComments: {
            removeAll: true
         }
      }))
      .pipe(removeComments())
      .pipe(rename({
         suffix: ".min",
         extname: ".css"
      }))
      .pipe(dest(path.build.css))
      .pipe(browserSync.reload({ stream: true }));
}

function js() {
   return src(path.src.js, { base: srcPath + "assets/js/" })
      .pipe(plumber())
      .pipe(rigger())
      .pipe(dest(path.build.js))
      .pipe(uglify())
      .pipe(rename({
         suffix: ".min",
         extname: ".js"
      }))
      .pipe(dest(path.build.js))
      .pipe(browserSync.reload({ stream: true }));
}

function images() {
   return src(path.src.images, { base: srcPath + "assets/images/" })
      .pipe(imagemin([
         imagemin.gifsicle({ interlaced: true }),
         imagemin.mozjpeg({ quality: 75, progressive: true }),
         imagemin.optipng({ optimizationLevel: 5 }),
         imagemin.svgo({
            plugins: [
               { removeViewBox: true },
               { cleanupIDs: false }
            ]
         })
      ]))
      .pipe(dest(path.build.images))
      .pipe(browserSync.reload({ stream: true }));
}

function fonts() {
   return src(path.src.fonts, { base: srcPath + "assets/fonts/" })
      .pipe(browserSync.reload({ stream: true }));
}

function clean() {
   return del(path.clean)
}

function watchFiles() {
   gulp.watch([path.watch.html], html)
   gulp.watch([path.watch.css], css)
   gulp.watch([path.watch.js], js)
   gulp.watch([path.watch.images], images)
   gulp.watch([path.watch.fonts], fonts)
}

const build = gulp.series(clean, gulp.parallel(html, css, js, images, fonts))
const watch = gulp.parallel(build, watchFiles, serve)

exports.html = html
exports.css = css
exports.js = js
exports.images = images
exports.fonts = fonts
exports.clean = clean
exports.build = build
exports.watch = watch
exports.default = watch

{
   "name": "front-end",
   "version": "1.0.0",
   "description": "web developer path",
   "author": "SvyaT_T",
   "devDependencies": {
      "browser-sync": "^2.27.10",
      "del": "^6.0.0",
      "gulp": "^4.0.2",
      "gulp-autoprefixer": "^8.0.0",
      "gulp-cssbeautify": "^3.0.1",
      "gulp-cssnano": "^2.1.3",
      "gulp-imagemin": "^7.1.0",
      "gulp-plumber": "^1.2.1",
      "gulp-rename": "^2.0.0",
      "gulp-rigger": "^0.5.8",
      "gulp-sass": "^5.1.0",
      "gulp-strip-css-comments": "^2.0.0",
      "gulp-uglify": "^3.0.2",
      "imagemin-gifsicle": "^7.0.0",
      "imagemin-mozjpeg": "^10.0.0",
      "imagemin-optipng": "^8.0.0",
      "imagemin-svgo": "^10.0.1",
      "panini": "^1.7.2",
      "sass": "^1.70.0"
   }
}
  • Вопрос задан
  • 49 просмотров
Подписаться 1 Простой Комментировать
Пригласить эксперта
Ответы на вопрос 1
imko
@imko
Senior Scratch Developer
Заменить обработчик события ошибки
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы