var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var cssMin = require('gulp-cssnano');
var maps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var html = require('gulp-html-minifier');
var rename = require('gulp-rename');
var minifyInline = require('gulp-minify-inline');
var imagemin = require('gulp-imagemin');
gulp.task('images', () =>
gulp.src([
'./data/**/*.jpg',
'./data/**/*.jpeg',
'./data/**/*.png',
'./App/Templates/New/img/*.png',
'./App/Templates/New/img/*.jpg',
'./App/Templates/New/img/*.jpeg'
])
.pipe(imagemin([
imagemin.gifsicle({interlaced: true}),
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 5}),
imagemin.svgo({
plugins: [
{removeViewBox: true},
{cleanupIDs: false}
]
})
]))
.pipe(gulp.dest('./data'))
);
gulp.task('build_css', function () {
gulp.src('./App/Templates/New/scss/**/*.scss')
.pipe(maps.init()).pipe(sass().on('error', sass.logError)).pipe(maps.write('./')).pipe(gulp.dest('./App/Templates/New/css/'));
});
gulp.task('js', function () {
gulp.src([
'./App/Templates/New/js_src/jquery.json.min.js',
'./App/Templates/New/js_src/popper.js',
'./App/Templates/New/js_src/bootstrap.min.js',
'./App/Templates/New/js_src/wow.min.js',
'./App/Templates/New/js_src/owl.carousel.js',
'./App/Templates/New/js_src/rod.js',
'./App/Templates/New/js_src/main.js'
])
.pipe(maps.init()).pipe(concat('glob_script.min.js')).pipe(uglify()).pipe(maps.write('./')).pipe(gulp.dest('./App/Templates/New/js/'));
});
gulp.task('html', function () {
gulp.src([
'./App/Templates/New/*_src.html',
'./App/Templates/New/**/*_src.html',
'./App/Templates/New/**/**/*_src.html'
])
.pipe(html({
collapseWhitespace: true,
includeAutoGeneratedTags: false,
removeComments: true,
keepClosingSlash: true,
caseSensitive: true,
minifyCSS: true,
minifyJS: true,
ignoreCustomFragments: ['/\<\-([а-яёa-z]{1,1}[а-яёa-z0-9_]*[а-яёa-z0-9]{1,1})\-\>/',
'/\<LANG\:([а-яёa-z]{1,1}[а-яёa-z0-9_]*[а-яёa-z0-9]{1,1})\/\>/i,/\<\-(AUTH)\:([a-zA-Z0-9_]+)\-\>/i']
}))
.pipe(rename(function (path) {
path.basename = path.basename.replace(/_src$/, '');
path.extname = ".html";
}))
.pipe(gulp.dest('./App/Templates/New/'));
});
gulp.task('finalize_css', ['build_css'], function () {
gulp.src([
'./App/Templates/New/css/animate/*.css',
'./App/Templates/New/css/fontawesome/*.css',
'./App/Templates/New/css/owl/*.css',
'./App/Templates/New/css/app/*.css'
])
.pipe(maps.init()).pipe(concat('glob_style.min.css')).pipe(cssMin()).pipe(maps.write('./')).pipe(gulp.dest('./App/Templates/New/css/'));
});
gulp.task('watch', function () {
gulp.watch('./App/Templates/New/**/*_src.html', ['html']);
gulp.watch('./App/Templates/New/js_src/*.js', ['js']);
gulp.watch('./App/Templates/New/scss/**/*.scss', ['build_css', 'finalize_css']);
});
gulp.task('default', ['watch', 'build_css', 'finalize_css', 'js', 'html']);