Skip to content

Commit

Permalink
Merge pull request #1 from AlexeyVin273/devbranch
Browse files Browse the repository at this point in the history
feat: Удаляет неиспользуемые в проекте модули. Производит рефакторинг кода карты.
  • Loading branch information
AlexeyVin273 authored Jul 18, 2023
2 parents da88d11 + 6593208 commit 43dc57d
Show file tree
Hide file tree
Showing 68 changed files with 568 additions and 2,740 deletions.
39 changes: 11 additions & 28 deletions gulp/optimizeImages.mjs
Original file line number Diff line number Diff line change
@@ -1,45 +1,28 @@
import gulp from 'gulp';
import rename from 'gulp-rename';
import imagemin from 'gulp-imagemin';
import webp from 'gulp-webp';
import svgstore from 'gulp-svgstore';
import pngQuant from 'imagemin-pngquant';
import mozJpeg from 'imagemin-mozjpeg';
import svgo from 'imagemin-svgo';
import svgo from 'gulp-svgmin';
import {stacksvg} from 'gulp-stacksvg';

const sprite = () =>
const stack = () =>
gulp
.src('source/img/sprite/*.svg')
.pipe(svgstore({inlineSvg: true}))
.pipe(rename('sprite.svg'))
.src('source/img/stack/*.svg')
.pipe(svgo())
.pipe(stacksvg({output: 'stack'}))
.pipe(gulp.dest('build/img'));

const optimizeSvg = () =>
gulp
.src('build/img/**/*.svg')
.pipe(
imagemin([
svgo({
plugins: [
{
name: 'removeViewBox',
active: false,
},
{
name: 'removeRasterImages',
active: true,
},
{
name: 'removeUselessStrokeAndFill',
active: false,
}],
})]))
.pipe(svgo())
.pipe(gulp.dest('build/img'));

const optimizeJpg = () =>
gulp
.src('build/img/**/*.{jpg,jpeg}')
.pipe(imagemin([mozJpeg({quality: 90, progressive: true})]))
.pipe(imagemin([mozJpeg({quality: 80, progressive: true})]))
.pipe(gulp.dest('build/img'));

const optimizePng = () =>
Expand All @@ -51,7 +34,7 @@ const optimizePng = () =>
speed: 1,
strip: true,
dithering: 1,
quality: [0.8, 0.9],
quality: [0.7, 0.8],
})]))
.pipe(gulp.dest('build/img'));

Expand All @@ -70,8 +53,8 @@ const createWebp = () => {
const root = '';
return gulp
.src(`source/img/${root}**/*.{png,jpg}`)
.pipe(webp({quality: 90}))
.pipe(webp({quality: 80}))
.pipe(gulp.dest(`source/img/${root}`));
};

export {sprite, createWebp, optimizeSvg, optimizePng, optimizeJpg};
export {stack, createWebp, optimizeSvg, optimizePng, optimizeJpg};
10 changes: 5 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import del from 'del';
import styles from './gulp/compileStyles.mjs';
import {copy, copyImages, copySvg} from './gulp/copyAssets.mjs';
import js from './gulp/compileScripts.mjs';
import {optimizeSvg, sprite, createWebp, optimizePng, optimizeJpg} from './gulp/optimizeImages.mjs';
import {optimizeSvg, stack, createWebp, optimizePng, optimizeJpg} from './gulp/optimizeImages.mjs';
import pug from './gulp/compilePug.mjs';

const server = browserSync.create();
Expand All @@ -29,7 +29,7 @@ const syncServer = () => {
gulp.watch('source/sass/**/*.{scss,sass}', streamStyles);
gulp.watch('source/js/**/*.{js,json}', gulp.series(js, refresh));
gulp.watch('source/data/**/*.{js,json}', gulp.series(copy, refresh));
gulp.watch('source/img/**/*.svg', gulp.series(copySvg, sprite, pug, refresh));
gulp.watch('source/img/**/*.svg', gulp.series(copySvg, stack, pug, refresh));
gulp.watch('source/img/**/*.{png,jpg,webp}', gulp.series(copyImages, pug, refresh));

gulp.watch('source/favicon/**', gulp.series(copy, refresh));
Expand All @@ -38,8 +38,8 @@ const syncServer = () => {
gulp.watch('source/*.php', gulp.series(copy, refresh));
};

const build = gulp.series(clean, copy, sprite, gulp.parallel(styles, js, pug, optimizePng, optimizeJpg, optimizeSvg));
const dev = gulp.series(clean, copy, sprite, gulp.parallel(styles, js, pug, optimizePng, optimizeJpg, optimizeSvg), syncServer);
const start = gulp.series(clean, copy, sprite, gulp.parallel(styles, js, pug), syncServer);
const build = gulp.series(clean, copy, stack, gulp.parallel(styles, js, pug, optimizePng, optimizeJpg, optimizeSvg));
const dev = gulp.series(clean, copy, stack, gulp.parallel(styles, js, pug, optimizePng, optimizeJpg, optimizeSvg), syncServer);
const start = gulp.series(clean, copy, stack, gulp.parallel(styles, js, pug), syncServer);

export {createWebp as webp, build, start, dev};
Loading

0 comments on commit 43dc57d

Please sign in to comment.