A
A
Aricus2018-06-25 21:08:45
Pug
Aricus, 2018-06-25 21:08:45

How to avoid gulp+pug error?

When building a project in gulp, I connect the translation of the pug template engine to html. Excluding the rest of the tasks, the gulpfile.js code is like this.

var gulp = require('gulp');
var watch = require('gulp-watch');
var pug = require('gulp-pug'); // Шаблонизация pug
var htmlbeautify = require('gulp-html-beautify'); // Приведение html в читаемый вид

gulp.task("pug", function() {
  var options = {
    	indentSize: 2
  };
    return watch("src/*.pug", { ignoreInitial: false })
        .pipe(pug())
  .pipe(htmlbeautify())
  .pipe(gulp.dest("dist/"));
});

// Запуск тасков по умолчанию
gulp.task("default", ["sass", "scripts", "pug", "else", "fonts", "imgs"]);

When run in console:

C:\Users\***\***\***\***>gulp
[21:03:52] Using gulpfile ~\Desktop\***\***\gulpfile.js
[21:03 :52] Starting 'sass'...
[21:03:52] Starting 'scripts'...
[21:03:52] Starting 'pug'...
[21:03:52] Starting 'else'. ..
[21:03:52] Starting 'fonts'...
[21:03:52] Starting 'imgs'...
(node:10408) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection
id: 1): [object Object]
(node:10408) [DEP0018] DeprecationWarning: Unhandled promise rejections are
deprecated. In the future, promise rejections that are not handled will terminate th
e Node.js process with a non-zero exit code.

the index.html file does not appear. The line .pipe(pug()) is responsible for the error: if you comment it out, the error does not pop up, and index.pug appears in the dist folder.
The error was in the index.pug file itself. For some reason, when an error occurs, the script does not end, and the error is not parsed, as in the case of other tasks. By the way, how can I close the question when I myself found the answer?

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