210 lines
4.9 KiB
JavaScript
210 lines
4.9 KiB
JavaScript
const {
|
|
dest,
|
|
parallel,
|
|
series,
|
|
src,
|
|
} = require('gulp');
|
|
const newer = require('gulp-newer');
|
|
const imagemin = require('gulp-imagemin');
|
|
const htmlclean = require('gulp-htmlclean');
|
|
const imageResize = require('gulp-image-resize');
|
|
const uglify = require('gulp-uglify-es').default;
|
|
|
|
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/'
|
|
},
|
|
images: {
|
|
src: 'src/images/*',
|
|
dest: 'dist/images/'
|
|
},
|
|
html: {
|
|
src: 'src/*.html',
|
|
dest: 'dist/'
|
|
},
|
|
pdf: {
|
|
src: 'src/pdf/*.pdf',
|
|
dest: 'dist/pdf/'
|
|
},
|
|
gfx: {
|
|
src: 'src/gfx/*',
|
|
dest: 'dist/gfx/'
|
|
},
|
|
font: {
|
|
src: 'src/font/*',
|
|
dest: 'dist/font/'
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
function gallery() {
|
|
return src(paths.gallery.src)
|
|
.pipe(newer(paths.gallery.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.gallery.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.backgrounds.dest));
|
|
}
|
|
|
|
function thumbnails() {
|
|
return src(paths.thumbnails.src)
|
|
.pipe(newer(paths.thumbnails.dest))
|
|
.pipe(imageResize({
|
|
width: 100,
|
|
height: 100,
|
|
crop: true,
|
|
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.header.dest));
|
|
}
|
|
|
|
function js() {
|
|
return src(paths.scripts.src)
|
|
.pipe(uglify())
|
|
.pipe(dest(paths.scripts.dest))
|
|
}
|
|
|
|
function css() {
|
|
return src(paths.css.src)
|
|
.pipe(newer(paths.css.dest))
|
|
.pipe(dest(paths.css.dest));
|
|
}
|
|
|
|
function html() {
|
|
return src(paths.html.src)
|
|
.pipe(newer(paths.html.dest))
|
|
.pipe(dest(paths.html.dest));
|
|
}
|
|
|
|
function pdf() {
|
|
return src(paths.pdf.src)
|
|
.pipe(newer(paths.pdf.dest))
|
|
.pipe(dest(paths.pdf.dest));
|
|
}
|
|
|
|
function gfx() {
|
|
return src(paths.gfx.src)
|
|
.pipe(newer(paths.gfx.dest))
|
|
.pipe(imagemin({
|
|
progressive: true,
|
|
optimizationLevel: 5,
|
|
svgoPlugins: [{
|
|
removeViewBox: false
|
|
}, {
|
|
removeUselessStrokeAndFill: false
|
|
}]
|
|
}))
|
|
.pipe(dest(paths.gfx.dest));
|
|
}
|
|
|
|
function images() {
|
|
return src(paths.images.src)
|
|
.pipe(newer(paths.images.dest))
|
|
.pipe(imagemin({
|
|
progressive: true,
|
|
optimizationLevel: 5,
|
|
svgoPlugins: [{
|
|
removeViewBox: false
|
|
}, {
|
|
removeUselessStrokeAndFill: false
|
|
}]
|
|
}))
|
|
.pipe(dest(paths.images.dest));
|
|
}
|
|
|
|
function font() {
|
|
return src(paths.font.src)
|
|
.pipe(newer(paths.font.dest))
|
|
.pipe(dest(paths.font.dest));
|
|
}
|
|
|
|
exports.scripts = series(js);
|
|
exports.images = parallel(gallery, thumbnails, backgrounds, header, gfx, images);
|
|
exports.default = series(parallel(html, pdf, font), js, css, parallel(gallery, thumbnails, backgrounds, header, gfx, images));
|