M
M
Michail Vasiliev2019-02-08 11:59:48
gulp.js
Michail Vasiliev, 2019-02-08 11:59:48

How to add gulp reload and error output to console?

Hello!
Can you please tell me how to add reloading components to my assembler, outputting errors to the console (instead of stopping work)?

spoiler
var browser	= require( 'browser-sync' )
    gulp = require( 'gulp' ),
    pug = require( 'gulp-pug' ),
    sass = require( 'gulp-sass' ),
    autoprefixer = require('gulp-autoprefixer'),
    concat = require('gulp-concat');

gulp.task( 'browser', function() {
  browser.init({
    server: {
      baseDir: './dist'
    },
    notify: false
  })
})

gulp.task( 'templates', function() {
  gulp.src( './src/templates/*.pug' )
    .pipe( pug({
      pretty: true
    }))
    .pipe( gulp.dest( './dist' ) )
})

gulp.task( 'styles',  function() {
  gulp.src( './src/**/*.sass' )
    .pipe( sass({
      outputStyle: 'compressed',
      errLogToConsole: true
    }))
    .pipe( autoprefixer({
      browsers: [ 'last 2 versions' ],
      cascade: false
    }))
    .pipe( concat( 'index.min.css' ))
    .pipe( gulp.dest( './dist/static/css' ) )
})

gulp.task( 'components-template', function() {
  gulp.src( './src/components/**/*.pug' )
    .pipe( pug({
      pretty: true
    }))
})

gulp.task( 'components-style', function() {
  gulp.src( './src/components/**/*.sass' )
    .pipe( sass({
      outputStyle: 'compressed',
      errLogToConsole: true
    }))
    .pipe( autoprefixer({
      browsers: [ 'last 2 versions' ],
      cascade: false
    }))
    .pipe( concat( 'index.min.css' ))
    .pipe( gulp.dest( './dist/static/css' ) )
})

gulp.task( 'render', gulp.parallel( 'templates', 'styles', 'components-template', 'components-style' ) )

gulp.task( 'dev', gulp.parallel( 'browser', 'render' ) )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2019-02-08
@iamvasiliev143

Maybe this? https://github.com/gulpjs/gulp/blob/master/docs/re...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question