@FlexFormi

Не работает build, dist — Gulp 4?

Здравствуйте , написал сайт, хочу его собрать и закинуть на сервер , в cmd после прописки gulp build
выдает ошибку, что команда не найдена, хотя она прописана

C:\Users\Dubra\Desktop\Jop\portfolio\Frontend\protezno\OptimizedHTML-4-master\app>gulp build
[09:07:48] Working directory changed to ~\Desktop\Jop\portfolio\Frontend\protezno\OptimizedHTML-4-master
[09:07:52] Using gulpfile ~\Desktop\Jop\portfolio\Frontend\protezno\OptimizedHTML-4-master\gulpfile.js
[09:07:52] Task never defined: build
[09:07:52] To list available tasks, try running: gulp --tasks


КОД САМОГО GULPFILE.JSМожет , что-то не так делаю, это мой первый проект, прошу помощи новичку

var syntax        = 'sass', // Syntax: sass or scss;
		gulpversion   = '4'; // Gulp version: 3 or 4

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'),
		autoprefixer  = require('gulp-autoprefixer'),
		notify        = require('gulp-notify'),
		rsync         = require('gulp-rsync');

gulp.task('browser-sync', function() {
	browserSync({
		server: {
			baseDir: 'app'
		},
		notify: false,
		// open: false,
		// online: false, // Work Offline Without Internet Connection
		// tunnel: true, tunnel: "projectname", // Demonstration page: http://projectname.localtunnel.me
	})
});

var path = {
	build: {
		html: 'build/',
		js: 'build/js/',
		css: 'build/css/'
		},
	src: {
		html: 'src/*.html',
		js: 'src/js/main.js',
		style: 'src/style/mail.scss'
	},
	watch: {
		html: 'src/**/*.html',
		js: 'src/js/**/*.js',
		style: 'src/style/**/*.scss'
	} ,
	clean: './build'
	};

gulp.task('dest', function () {

    var cssDist = gulp.src([
        'app/css/style.min.css',
    ]).pipe(gulp.dest('dist/css'));
    var fontsDist = gulp.src('app/fonts/**/*').pipe(gulp.dest('dist/fonts'));
    var jsDist = gulp.src(['app/js/**/*', '!app/js/common.js']).pipe(gulp.dest('dist/js'));
    var htmlDist = gulp.src(['app/*.html', '!app/template.html']).pipe(gulp.dest('dist'));
    var imgDist = gulp.src('app/img/**/*')
        .pipe(cache(imagemin({
            interlaced: true,
            progressive: true,
            svgoPlugins: [{
            removeViewBox: false
            }],
            use: [pngquant()]
        })))
        .pipe(gulp.dest('dist/img'));

    return cssDist, fontsDist, jsDist, htmlDist, imgDist;

});

gulp.task('build', gulp.series('clean', 'sass', 'js', 'dest'));



gulp.task('styles', function() {
	return gulp.src('app/'+syntax+'/**/*.'+syntax+'')
	.pipe(sass({ outputStyle: 'expand' }).on("error", notify.onError()))
	.pipe(rename({ suffix: '.min', prefix : '' }))
	.pipe(autoprefixer(['last 15 versions']))
	.pipe(cleancss( {level: { 1: { specialComments: 0 } } })) // Opt., comment out when debugging
	.pipe(gulp.dest('app/css'))
	.pipe(browserSync.stream())
});



gulp.task('sass', function() {
	return gulp.src('app/'+syntax+'/**/*.'+syntax+'')
	.pipe(sass({ outputStyle: 'expand' }).on("error", notify.onError()))
	.pipe(rename({ suffix: '.min', prefix : '' }))
	.pipe(autoprefixer(['last 15 versions']))
	  .pipe(cleancss( {level: { 1: { specialComments: 0 } } })) // Opt., comment out when debugging
	.pipe(gulp.dest('app/css'))
	.pipe(browserSync.reload({stream:true}))
});

gulp.task('scripts', function() {
	return gulp.src([
		'app/libs/jquery/dist/jquery.min.js',
		'app/libs/equalHeights/jquery.equalheights.js',
		'app/libs/mmenu/dist/jquery.mmenu.all.js',
		'app/libs/fotorama/vendor/assets/javascripts/fotorama.js',
		'app/libs/owl.carousel/dist/owl.carousel.min.js',
		'app/libs/selectize/dist/js/standalone/selectize.min.js',
		'app/js/common.js', // Always at the end
		])
	.pipe(concat('scripts.min.js'))
	// .pipe(uglify()) // Mifify js (opt.)
	.pipe(gulp.dest('app/js'))
	.pipe(browserSync.reload({ stream: true }))
});

gulp.task('code', function() {
	return gulp.src('app/*.html')
	.pipe(browserSync.reload({ stream: true }))
});

gulp.task('rsync', function() {
	return gulp.src('app/**')
	.pipe(rsync({
		root: 'app/',
		hostname: 'username@yousite.com',
		destination: 'yousite/public_html/',
		// include: ['*.htaccess'], // Includes files to deploy
		exclude: ['**/Thumbs.db', '**/*.DS_Store'], // Excludes files from deploy
		recursive: true,
		archive: true,
		silent: false,
		compress: true
	}))
});

gulp.task('html:build', function(){
	gulp.src(path.src.html)
		.pipe(rigger())
		.pipe(gulp.dest(path.build.html))
		.pipe(reload({stream: true}));
});

if (gulpversion == 3) {
	gulp.task('watch', ['styles', 'scripts', 'browser-sync'], function() {
		gulp.watch('app/'+syntax+'/**/*.'+syntax+'', ['styles']);
		gulp.watch(['libs/**/*.js', 'app/js/common.js'], ['scripts']);
		gulp.watch('app/*.html', ['code'])
	});
	gulp.task('default', ['watch']);
}

if (gulpversion == 4) {
	gulp.task('watch', function() {
		gulp.watch('app/'+syntax+'/**/*.'+syntax+'', gulp.parallel('styles'));
		gulp.watch(['libs/**/*.js', 'app/js/common.js'], gulp.parallel('scripts'));
		gulp.watch('app/*.html', gulp.parallel('code'))
	});
	gulp.task('default', gulp.parallel('styles', 'scripts', 'browser-sync', 'watch'));
}
  • Вопрос задан
  • 496 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы