Как исправить ошибку.
'pug' errored after 2.35 ms
[19:10:37] TypeError: pug is not a function
at Gulp. (/Users/aleksandrsidorov/Desktop/Верстка/Сайт/Стар с pug/gulpfile.js:71:11)
..........
var gulp = require('gulp'),
gutil = require('gulp-util' ),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
concat = require('gulp-concat'),
pug = require('pug'),
uglify = require('gulp-uglify'),
cleanCSS = require('gulp-clean-css'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
del = require('del'),
imagemin = require('gulp-imagemin'),
cache = require('gulp-cache'),
autoprefixer = require('gulp-autoprefixer'),
ftp = require('vinyl-ftp'),
notify = require("gulp-notify"),
rsync = require('gulp-rsync');
// Скрипты проекта
gulp.task('common-js', function() {
return gulp.src([
'app/js/common.js',
])
// .pipe(plumber())
.pipe(concat('common.min.js'))
.pipe(uglify())
.pipe(gulp.dest('app/js'));
});
gulp.task('js', ['common-js'], function() {
return gulp.src([
'app/libs/jquery/jquery.min.js',
'app/libs/SliderSlick/slick.min.js',
'app/libs/Wowjs/wow.min.js',
'app/libs/equalheights/jquery.equalheights.js',
'app/js/common.min.js', // Всегда в конце
])
.pipe(concat('scripts.min.js'))
// .pipe(uglify()) // Минимизировать весь js (на выбор)
.pipe(gulp.dest('app/js'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('browser-sync', function() {
browserSync({
browser: 'google chrome',
server: {
baseDir: 'app'
},
notify: false,
// tunnel: true,
});
});
gulp.task('sass', function() {
return gulp.src('app/scss/**/*.scss')
// .pipe(plumber())
.pipe(sass({outputStyle: 'expand'}).on("error", notify.onError()))
.pipe(rename({suffix: '.min', prefix : ''}))
.pipe(autoprefixer(['last 15 versions']))
.pipe(cleanCSS()) // Опционально, закомментировать при отладке
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('pug', function () {
return gulp.src('app/pug/**/*.pug')
// .pipe(plumber())
.pipe(pug({pretty: true}))
.pipe(gulp.dest('app'))
.pipe(browserSync.stream());
});
gulp.task('watch', ['sass', 'js', 'browser-sync'], function() {
gulp.watch('app/scss/**/*.scss', ['sass']);
gulp.watch(['app/*.pug', 'app/pug/**/*.pug'], ['pug']);
gulp.watch(['libs/**/*.js', 'app/js/common.js'], ['js']);
gulp.watch('app/*.html', browserSync.reload);
});
gulp.task('imagemin', function() {
return gulp.src('app/img/**/*')
.pipe(cache(imagemin())) // Cache Images
.pipe(gulp.dest('dist/img'));
});
gulp.task('build', ['removedist', 'imagemin', 'sass', 'js'], function() {
var buildFiles = gulp.src([
'app/*.html',
'app/.htaccess',
]).pipe(gulp.dest('dist'));
var buildCss = gulp.src([
'app/css/main.min.css',
]).pipe(gulp.dest('dist/css'));
var buildJs = gulp.src([
'app/js/scripts.min.js',
]).pipe(gulp.dest('dist/js'));
var buildFonts = gulp.src([
'app/fonts/**/*',
]).pipe(gulp.dest('dist/fonts'));
});
gulp.task('deploy', function() {
var conn = ftp.create({
host: 'hostname.com',
user: 'username',
password: 'userpassword',
parallel: 10,
log: gutil.log
});
var globs = [
'dist/**',
'dist/.htaccess',
];
return gulp.src(globs, {buffer: false})
.pipe(conn.dest('/path/to/folder/on/server'));
});
gulp.task('rsync', function() {
return gulp.src('dist/**')
.pipe(rsync({
root: 'dist/',
hostname: 'username@yousite.com',
destination: 'yousite/public_html/',
// include: ['*.htaccess'], // Скрытые файлы, которые необходимо включить в деплой
recursive: true,
archive: true,
silent: false,
compress: true
}));
});
gulp.task('removedist', function() { return del.sync('dist'); });
gulp.task('clearcache', function () { return cache.clearAll(); });
gulp.task('default', ['watch']);
..........
"devDependencies": {
"browser-sync": "^2.23.5",
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^4.1.0",
"gulp-cache": "^1.0.2",
"gulp-clean-css": "^3.9.2",
"gulp-concat": "^2.6.1",
"gulp-imagemin": "^4.1.0",
"gulp-notify": "^3.2.0",
"gulp-plumber": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-rsync": "0.0.8",
"gulp-sass": "^3.1.0",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.8",
"pug": "^2.0.0-rc.4",
"vinyl-ftp": "^0.6.0"
}