Z
Z
Zbiten2017-01-12 01:08:41
gulp.js
Zbiten, 2017-01-12 01:08:41

Where can I find a ready task for gulp-pug + browsersync?

Actually the question is in the title.
You need a task to autocompile pug to html, plus watch for the whole thing.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2017-01-12
@werty1001

More or less like this:

// Require
var gulp = require( 'gulp' );
var pug = require( 'gulp-pug' );
var browserSync = require( 'browser-sync' ).create();

// Compile
gulp.task( 'pug', function () {
  return gulp.src( 'pug/*.pug', { since: gulp.lastRun( 'pug' ) } )
  .pipe( pug() )
  .pipe( gulp.dest( './dist/' ) );
});

// BrowserSync
gulp.task( 'browsersync', function () {
  browserSync.init({ server: './dist/' });
  return browserSync.watch( '**/*.*' ).on( 'change', browserSync.reload );
});

// Watch
gulp.task( 'watch', function () {

  return gulp.watch( 'pug/*.pug', gulp.series( 'pug' ) );

});

// Default task
gulp.task( 'default', gulp.series( 'pug', gulp.parallel( 'browsersync', 'watch' ) ) );

// Пример для gulp#4.0

M
Make Now, 2017-12-24
@makenow

http://www.4webfan.ru/pug-gulp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question