Shoora
5/3/2019 - 12:38 AM

gulpfile.js - opencart 2.3

var gulp 		 = require('gulp'),
    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'),
    notify 		 = require('gulp-notify'),
    ftp		     = require('vinyl-ftp'),
    gutil        = require('gulp-util');

	
/* main js */
gulp.task('main-js', function() {
    return gulp.src([
        'catalog/view/theme/storeset/js/main.js',
    ])
        .pipe(concat('main.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('catalog/view/theme/storeset/js/'));
});


/* libs js */
gulp.task('js', ['main-js'], function() {
    return gulp.src([
        'catalog/view/theme/storeset/js/main.min.js'
    ])
        .pipe(concat('scriptsSecond.min.js'))
        .pipe(uglify()) // Optional
        .pipe(gulp.dest('catalog/view/theme/storeset/js/'))
        .pipe(browserSync.reload({stream: true}));
});


/* browser sync */
gulp.task('browser-sync', function() {
    browserSync({
        proxy: "artpodshipnikcomua",
        notify: false
    });
});


/* sass */
gulp.task('sass', function() {
    return gulp.src('catalog/view/theme/storeset/sass/**/*.sass')
        .pipe(sass({outputStyle: 'expand'}).on("error", notify.onError()))
        .pipe(rename({suffix: '.min', prefix: ''}))
        .pipe(autoprefixer(['last 15 versions']))
        .pipe(cleanCSS()) // Optional
        .pipe(gulp.dest('catalog/view/theme/storeset/stylesheet/'))
        .pipe(browserSync.reload({stream: true}));
});


/* watch */
gulp.task('watch', ['sass', 'js', 'browser-sync'], function() {
    gulp.watch([
        'catalog/view/theme/storeset/libs/**/*.js',
        'catalog/view/theme/storeset/js/main.js'],
        ['js']
    );
    gulp.watch('catalog/view/theme/storeset/template/**/*.tpl', browserSync.reload);
    gulp.watch('catalog/view/theme/storeset/sass/**/*.sass', ['sass']);
});


/* deploy */
gulp.task('deploy', function() {
	var conn = ftp.create({
        host:      '',
        user:      '',
        password:  '',
        parallel:  10,
        log: gutil.log
    });
    var globs = [
        'catalog/view/theme/storeset/**'
    ];
    return gulp.src(globs, {buffer: false})
        .pipe(conn.dest('/catalog/view/theme/storeset/'));
});


/* default */
gulp.task('default', ['watch']);