const { dest, parallel, series, src, watch, } = require('gulp'); const newer = require('gulp-newer'); const imagemin = require('gulp-imagemin'); const htmlclean = require('gulp-htmlclean'); const imageResize = require('gulp-image-resize'); const inject = require('gulp-inject'); const uglify = require('gulp-uglify-es').default; const favicons = require('gulp-favicons'); const sass = require('gulp-sass'); const browserSync = require('browser-sync'); var server = browserSync.create(); const paths = { scripts: { src: 'src/js/*.js', dest: 'dist/js/' }, css: { src: 'src/css/*.css', dest: 'dist/css' }, gallery: { src: 'src/img/gallery/*.jpg', dest: 'dist/img/gallery/' }, backgrounds: { src: 'src/img/backgrounds/*.jpg', dest: 'dist/img/backgrounds/' }, header: { src: 'src/img/header/*.jpg', dest: 'dist/img/header/' }, thumbnails: { src: 'src/img/gallery/*.jpg', dest: 'dist/img/gallery/thumbs/' }, html: { src: 'src/*.html', dest: 'dist/' }, pdf: { src: 'src/pdf/*.pdf', dest: 'dist/pdf/' }, gfx: { src: 'src/gfx/*.pdf', dest: 'dist/gfx/' }, font: { src: 'src/font/*.pdf', dest: 'dist/font/' } }; function gallery() { return src(paths.gallery.src) .pipe(newer(paths.images.dest)) .pipe(imageResize({ width: 1200, height: 900, crop: false, upscale: false })) .pipe(imagemin({ progressive: true, optimizationLevel: 5, svgoPlugins: [{ removeViewBox: false }, { removeUselessStrokeAndFill: false }] })) .pipe(dest(paths.images.dest)); } function backgrounds() { return src(paths.backgrounds.src) .pipe(newer(paths.backgrounds.dest)) .pipe(imageResize({ width: 2400, height: 1800, crop: false, upscale: false })) .pipe(imagemin({ progressive: true, optimizationLevel: 5, svgoPlugins: [{ removeViewBox: false }, { removeUselessStrokeAndFill: false }] })) .pipe(dest(paths.images.dest)); } function thumbnails() { return src(paths.thumbnails.src) .pipe(newer(paths.thumbnails.dest)) .pipe(imageResize({ width: 100, height: 100, crop: false, upscale: false })) .pipe(imagemin({ progressive: true, optimizationLevel: 5, svgoPlugins: [{ removeViewBox: false }, { removeUselessStrokeAndFill: false }] })) .pipe(dest(paths.thumbnails.dest)); } function header() { return src(paths.header.src) .pipe(newer(paths.header.dest)) .pipe(imageResize({ width: 1000, height: 1000, crop: false, upscale: false })) .pipe(imagemin({ progressive: true, optimizationLevel: 5, svgoPlugins: [{ removeViewBox: false }, { removeUselessStrokeAndFill: false }] })) .pipe(dest(paths.thumbnails.dest)); } function js() { return src(paths.scripts.src) .pipe(uglify()) .pipe(dest(paths.scripts.dest)) } function css() { return src(paths.css.src) .pipe(dest(paths.css.dest)); } function html() { return src(paths.html.src) .pipe(newer(paths.html.dest)) .pipe(htmlclean()) .pipe(dest(paths.html.dest)); } function pdf() { return src(paths.pdf.src) .pipe(dest(paths.pdf.dest)); } function gfx() { return src(paths.gfx.src) .pipe(dest(paths.gfx.dest)); } function font() { return src(paths.font.src) .pipe(dest(paths.font.dest)); } function allImages() { return parallel(gallery, thumbnails, backgrounds, header, gfx); } exports.images = allImages; exports.default = series(parallel(html, pdf, font), js, css, allImages);