[TASK] update gulp

This commit is contained in:
Christian Seyfferth 2020-05-12 17:46:20 +02:00
parent 590a5212f4
commit 758381e57b
3 changed files with 60 additions and 19 deletions

View File

@ -3,19 +3,12 @@ const {
parallel, parallel,
series, series,
src, src,
watch,
} = require('gulp'); } = require('gulp');
const newer = require('gulp-newer'); const newer = require('gulp-newer');
const imagemin = require('gulp-imagemin'); const imagemin = require('gulp-imagemin');
const htmlclean = require('gulp-htmlclean'); const htmlclean = require('gulp-htmlclean');
const imageResize = require('gulp-image-resize'); const imageResize = require('gulp-image-resize');
const inject = require('gulp-inject');
const uglify = require('gulp-uglify-es').default; 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 = { const paths = {
scripts: { scripts: {
@ -42,6 +35,10 @@ const paths = {
src: 'src/img/gallery/*.jpg', src: 'src/img/gallery/*.jpg',
dest: 'dist/img/gallery/thumbs/' dest: 'dist/img/gallery/thumbs/'
}, },
images: {
src: 'src/images/*',
dest: 'dist/images/'
},
html: { html: {
src: 'src/*.html', src: 'src/*.html',
dest: 'dist/' dest: 'dist/'
@ -51,11 +48,11 @@ const paths = {
dest: 'dist/pdf/' dest: 'dist/pdf/'
}, },
gfx: { gfx: {
src: 'src/gfx/*.pdf', src: 'src/gfx/*',
dest: 'dist/gfx/' dest: 'dist/gfx/'
}, },
font: { font: {
src: 'src/font/*.pdf', src: 'src/font/*',
dest: 'dist/font/' dest: 'dist/font/'
} }
}; };
@ -65,7 +62,7 @@ const paths = {
function gallery() { function gallery() {
return src(paths.gallery.src) return src(paths.gallery.src)
.pipe(newer(paths.images.dest)) .pipe(newer(paths.gallery.dest))
.pipe(imageResize({ .pipe(imageResize({
width: 1200, width: 1200,
height: 900, height: 900,
@ -81,7 +78,7 @@ function gallery() {
removeUselessStrokeAndFill: false removeUselessStrokeAndFill: false
}] }]
})) }))
.pipe(dest(paths.images.dest)); .pipe(dest(paths.gallery.dest));
} }
function backgrounds() { function backgrounds() {
@ -102,7 +99,7 @@ function backgrounds() {
removeUselessStrokeAndFill: false removeUselessStrokeAndFill: false
}] }]
})) }))
.pipe(dest(paths.images.dest)); .pipe(dest(paths.backgrounds.dest));
} }
function thumbnails() { function thumbnails() {
@ -111,7 +108,7 @@ function thumbnails() {
.pipe(imageResize({ .pipe(imageResize({
width: 100, width: 100,
height: 100, height: 100,
crop: false, crop: true,
upscale: false upscale: false
})) }))
.pipe(imagemin({ .pipe(imagemin({
@ -144,7 +141,7 @@ function header() {
removeUselessStrokeAndFill: false removeUselessStrokeAndFill: false
}] }]
})) }))
.pipe(dest(paths.thumbnails.dest)); .pipe(dest(paths.header.dest));
} }
function js() { function js() {
@ -155,6 +152,7 @@ function js() {
function css() { function css() {
return src(paths.css.src) return src(paths.css.src)
.pipe(newer(paths.css.dest))
.pipe(dest(paths.css.dest)); .pipe(dest(paths.css.dest));
} }
@ -167,21 +165,46 @@ function html() {
function pdf() { function pdf() {
return src(paths.pdf.src) return src(paths.pdf.src)
.pipe(newer(paths.pdf.dest))
.pipe(dest(paths.pdf.dest)); .pipe(dest(paths.pdf.dest));
} }
function gfx() { function gfx() {
return src(paths.gfx.src) 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)); .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() { function font() {
return src(paths.font.src) return src(paths.font.src)
.pipe(newer(paths.font.dest))
.pipe(dest(paths.font.dest)); .pipe(dest(paths.font.dest));
} }
function allImages() { exports.scripts = series(js);
return parallel(gallery, thumbnails, backgrounds, header, gfx); 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));
exports.images = allImages;
exports.default = series(parallel(html, pdf, font), js, css, allImages);

17
package-lock.json generated
View File

@ -2832,6 +2832,17 @@
} }
} }
}, },
"gulp-htmlclean": {
"version": "2.7.22",
"resolved": "https://registry.npmjs.org/gulp-htmlclean/-/gulp-htmlclean-2.7.22.tgz",
"integrity": "sha1-p4Ed6NEiESKuYNZgygFwtltpjd4=",
"dev": true,
"requires": {
"htmlclean": "~3.0.8",
"plugin-error": "^1.0.1",
"through2": "^2.0.3"
}
},
"gulp-image-resize": { "gulp-image-resize": {
"version": "0.13.1", "version": "0.13.1",
"resolved": "https://registry.npmjs.org/gulp-image-resize/-/gulp-image-resize-0.13.1.tgz", "resolved": "https://registry.npmjs.org/gulp-image-resize/-/gulp-image-resize-0.13.1.tgz",
@ -3056,6 +3067,12 @@
"dev": true, "dev": true,
"optional": true "optional": true
}, },
"htmlclean": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/htmlclean/-/htmlclean-3.0.8.tgz",
"integrity": "sha1-zqRRz1OZ1AGDhqVxKUifLWMOYrA=",
"dev": true
},
"http-cache-semantics": { "http-cache-semantics": {
"version": "3.8.1", "version": "3.8.1",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz",

View File

@ -6,6 +6,7 @@
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-htmlclean": "^2.7.22",
"gulp-image-resize": "^0.13.1", "gulp-image-resize": "^0.13.1",
"gulp-imagemin": "^7.1.0", "gulp-imagemin": "^7.1.0",
"gulp-newer": "^1.4.0", "gulp-newer": "^1.4.0",