// 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
gulp.task( 'pug', function () {
return gulp.src( 'pug/*.pug', { since: gulp.lastRun( 'pug' ) } )
.pipe( pug() )
.pipe( gulp.dest( './dist/' ) );
});
var gulp = require('gulp');
var spritesmith = require('gulp.spritesmith');
gulp.task('sprite', function () {
var spriteData = gulp.src('images/*.png').pipe(spritesmith({
imgName: 'sprite.png',
cssName: 'sprite.css'
}));
spriteData.css.pipe(gulp.dest('path/to/output/')); // CSS
return spriteData.img.pipe(gulp.dest('path/to/output/')); // IMG
});
var task = function(name, path, options) {
options = options || {};
return gulp.task(name, function(cb) {
var call = require(path).call(this, options);
return call(cb);
});
};
var rename = require("gulp-rename");
gulp.src("./*.html")
.pipe(rename(function (path) {
path.extname = ".php"
}))
.pipe(gulp.dest("./dist"));
var concat = require('gulp-concat');
gulp.task('stylus', function() {
gulp.src('./assets/blocks/*/*.styl')
.pipe(plumber(configs.plumberError))
.pipe(sourcemaps.init())
.pipe(stylus())
.pipe(autoprefixer())
.pipe(concat('style.css'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(path.public + '/css'))
.pipe(reload(configs.allowStreamReload));
});