var gulp = require('gulp'),
gutil = require('gulp-util' ),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
cleanCSS = require('gulp-clean-css'),
rename = require('gulp-rename'),
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('browser-sync', function() {
browserSync({
server: {
baseDir: 'app'
},
notify: false,
// tunnel: true,
// tunnel: "projectmane", //Demonstration page: http://projectmane.localtunnel.me
});
});
// Пользовательские скрипты проекта
gulp.task('common-js', function() {
return gulp.src([
'app/js/common.js',
])
.pipe(concat('common.min.js'))
.pipe(uglify())
.pipe(gulp.dest('app/js'));
});
gulp.task('js', ['common-js'], function() {
return gulp.src([
'app/libs/jquery/dist/jquery.min.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('sass', function() {
return gulp.src('app/sass/**/*.sass')
.pipe(sass({outputStyle: 'expanded'}).on("error", notify.onError()))
.pipe(rename({suffix: '.min', prefix : ''}))
.pipe(autoprefixer(['last 15 versions']))
.pipe(cleanCSS()) // Опционально, закомментировать при отладке
.pipe(gulp.dest('app/css'))
.pipe(browserSync.stream())
});
gulp.task('watch', ['sass', 'js', 'browser-sync'], function() {
gulp.watch('app/sass/**/*.sass', ['sass']);
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']);<code lang="javascript">
</code>
<b>Конечно же, все папки прописал, под свои, но при запуске через командную строку выходит ошибка
P.S</b>
C:\Users\User\Desktop\neon.hit\html>gulp
assert.js:374
throw err;
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (C:\Users\User\Desktop\neon.hit\html\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (C:\Users\User\Desktop\neon.hit\html\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (C:\Users\User\Desktop\neon.hit\html\gulpfile.js:39:6)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at execute (C:\Users\User\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:36:18) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}