Answer the question
In order to leave comments, you need to log in
Gulp how to optimize jade generation?
Hello!
Who understands gulp tell me what the problem is.
It takes a very long time to generate jade, everything else is generated quickly. Jade generates 118 files, which are organized into folders, the maximum depth being 3 folders. generated about 40 seconds.
At the same time, the same number of sass files and the same structure as jade is generated instantly.
var gulp = require('gulp'),
browserSync = require('browser-sync'),
sass = require('gulp-sass'),
jade = require('gulp-jade'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
spritesmith = require('gulp.spritesmith'),
buffer = require('vinyl-buffer'),
csso = require('gulp-csso'),
imagemin = require('gulp-imagemin'),
merge = require('merge-stream'),
reload = browserSync.reload;
gulp.task('jade', function() {
return gulp.src(['./app/jade/**/*.jade', '!./app/jade/**/_*.jade'])
.pipe(plumber())
.pipe(jade({pretty: true}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('jade-watch', ['jade'], reload);
gulp.task('sass', function () {
return gulp.src(['./app/scss/**/*.scss', '!./app/sass/**/_*.scss'])
.pipe(plumber())
.pipe(sass())
.pipe(csso())
.pipe(gulp.dest('./dist/css'))
.pipe(reload({stream: true}));
});
gulp.task('jsConcat', function () {
return gulp.src('./app/js/all/*.js')
.pipe(concat('all.js', {newLine: ';'}))
.pipe(gulp.dest('./dist/js/'))
.pipe(browserSync.stream());
});
gulp.task('jsSync', function () {
return gulp.src(['./app/js/**/*.js', '!./app/js/all/*'])
.pipe(plumber())
.pipe(gulp.dest('./dist/js/'))
.pipe(browserSync.stream());
});
gulp.task('sprite', function () {
var spriteData = gulp.src('./app/images/sprite/*.png').pipe(spritesmith({
imgName: 'sprite.png',
imgPath: '../images/sprite.png',
cssName: 'sprite.css'
}));
var imgStream = spriteData.img
.pipe(buffer())
.pipe(imagemin())
.pipe(gulp.dest('./dist/images/'));
var cssStream = spriteData.css
//.pipe(csso())
.pipe(gulp.dest('./dist/css/'));
return merge(imgStream, cssStream);
});
gulp.task('compress', function(){
gulp.src(['./app/images/**/*.{jpg,jpeg,png,gif}', '!./app/images/sprite/**/*.{jpg,jpeg,png,gif}', '!./app/images/svg/**/*.{jpg,jpeg,png,gif}'])
.pipe(plumber())
.pipe(imagemin())
.pipe(gulp.dest('./dist/images'));
});
gulp.task('watch', function () {
gulp.watch('./app/scss/**/*.scss', ['sass']);
gulp.watch('./app/jade/**/*.jade', ['jade']);
gulp.watch('./app/js/**/*.js', ['jsSync']);
gulp.watch('./app/js/all/**/*.js', ['jsConcat']);
gulp.watch('./app/jade/**/*.jade', ['jade-watch']);
});
gulp.task('browser-sync', function () {
browserSync.init({
port: 1337,
server: {
baseDir: './dist/'
}
});
});
gulp.task('default', ['jade', 'sass', 'jsConcat', 'jsSync', 'watch', 'browser-sync']);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question