Skip to content

Commit

Permalink
Webp only
Browse files Browse the repository at this point in the history
  • Loading branch information
efiand committed Sep 17, 2023
1 parent f0eeb07 commit 095e651
Show file tree
Hide file tree
Showing 44 changed files with 19 additions and 43 deletions.
10 changes: 0 additions & 10 deletions gulp/build-webp.js

This file was deleted.

2 changes: 2 additions & 0 deletions gulp/place-images.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import clean from 'gulp-clean';
import createWebp from 'gulp-webp';
import gulp from 'gulp';
import optimizeImages from 'gulp-imagemin';
import optimizeJpeg from 'imagemin-mozjpeg';
Expand All @@ -17,6 +18,7 @@ const placeImages = () =>
])
)
.pipe(clean())
.pipe(createWebp({ quality: 75 }))
.pipe(gulp.dest('source/static/images'));

export default placeImages;
4 changes: 1 addition & 3 deletions gulp/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import buildScripts from './build-scripts.js';
import buildSprite from './build-sprite.js';
import buildSsrScript from './build-ssr-script.js';
import buildStyles from './build-styles.js';
import buildWebp from './build-webp.js';
import gulp from 'gulp';
import lintMarkdown from './lint-markdown.js';
import lintScripts from './lint-scripts.js';
Expand Down Expand Up @@ -64,8 +63,7 @@ const watch = () => {
gulp.watch('source/place/pixelperfect/**/*.{jpg,png}', placePixelperfectImages);
gulp.watch('source/place/sprite/**/*.svg', placeSpriteIcons);
gulp.watch('source/sprite/**/*.svg', gulp.series(buildSprite, reload));
gulp.watch(['source/static/**', '!source/static/images/**/*.{jpg,png}'], reload);
gulp.watch('source/static/images/**/*.{jpg,png}', gulp.series(buildWebp, reload));
gulp.watch('source/static/**', reload);
gulp.watch(['.stylelintrc', 'source/styles/**/*.scss'], gulp.parallel(buildStyles, lintStyles));
};

Expand Down
3 changes: 1 addition & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import buildScripts from './gulp/build-scripts.js';
import buildSprite from './gulp/build-sprite.js';
import buildSsrScript from './gulp/build-ssr-script.js';
import buildStyles from './gulp/build-styles.js';
import buildWebp from './gulp/build-webp.js';
import copyStatic from './gulp/copy-static.js';
import { deleteAsync } from 'del';
import gulp from 'gulp';
Expand Down Expand Up @@ -41,7 +40,7 @@ const build = gulp.series(
placePixelperfectImages,
placeSpriteIcons
),
gulp.parallel(buildSprite, buildWebp),
buildSprite,
isDev ? watch : gulp.parallel(buildPages, copyStatic),
cleanOnEnd
);
Expand Down
20 changes: 12 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion source/scripts/blocks/cards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<PictureBlock
class="cards__picture"
:fileName="image.fileName"
:extName="image.extName"
:alt="image.alt"
:width="image.width"
:height="image.height"
Expand Down
6 changes: 1 addition & 5 deletions source/scripts/blocks/picture.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<template>
<picture>
<source
type="image/webp"
:srcset="`images/${fileName}.webp 1x, images/${fileName}@2x.webp 2x`"
/>
<img
:src="`images/${fileName}.${extName}`"
:srcset="`images/${fileName}@2x.${extName} 2x`"
Expand Down Expand Up @@ -32,7 +28,7 @@
},
extName: {
type: String,
default: 'jpg'
default: 'webp'
},
width: {
type: String,
Expand Down
Binary file removed source/static/images/accent-background.jpg
Binary file not shown.
Binary file added source/static/images/accent-background.webp
Binary file not shown.
Binary file removed source/static/images/accent-background@2x.jpg
Binary file not shown.
Binary file added source/static/images/accent-background@2x.webp
Binary file not shown.
Binary file removed source/static/images/hero-background.jpg
Binary file not shown.
Binary file added source/static/images/hero-background.webp
Binary file not shown.
Binary file removed source/static/images/hero-background@2x.jpg
Binary file not shown.
Binary file added source/static/images/hero-background@2x.webp
Binary file not shown.
Binary file removed source/static/images/hotel-1.jpg
Binary file not shown.
Binary file added source/static/images/hotel-1.webp
Binary file not shown.
Binary file removed source/static/images/hotel-1@2x.jpg
Binary file not shown.
Binary file added source/static/images/hotel-1@2x.webp
Binary file not shown.
Binary file removed source/static/images/hotel-2.jpg
Binary file not shown.
Binary file added source/static/images/hotel-2.webp
Binary file not shown.
Binary file removed source/static/images/hotel-2@2x.jpg
Binary file not shown.
Binary file added source/static/images/hotel-2@2x.webp
Binary file not shown.
Binary file removed source/static/images/hotel-3.jpg
Binary file not shown.
Binary file added source/static/images/hotel-3.webp
Binary file not shown.
Binary file removed source/static/images/hotel-3@2x.jpg
Binary file not shown.
Binary file added source/static/images/hotel-3@2x.webp
Binary file not shown.
Binary file removed source/static/images/hotel-4.jpg
Binary file not shown.
Binary file added source/static/images/hotel-4.webp
Binary file not shown.
Binary file removed source/static/images/hotel-4@2x.jpg
Binary file not shown.
Binary file added source/static/images/hotel-4@2x.webp
Binary file not shown.
Binary file removed source/static/images/main-header-background.jpg
Binary file not shown.
Binary file added source/static/images/main-header-background.webp
Binary file not shown.
Binary file removed source/static/images/main-header-background@2x.jpg
Binary file not shown.
Binary file not shown.
Binary file removed source/static/images/photo-1.jpg
Binary file not shown.
Binary file added source/static/images/photo-1.webp
Binary file not shown.
Binary file removed source/static/images/photo-1@2x.jpg
Binary file not shown.
Binary file added source/static/images/photo-1@2x.webp
Binary file not shown.
Binary file removed source/static/images/photo-2.jpg
Binary file not shown.
Binary file added source/static/images/photo-2.webp
Binary file not shown.
Binary file removed source/static/images/photo-2@2x.png
Binary file not shown.
Binary file added source/static/images/photo-2@2x.webp
Binary file not shown.
16 changes: 2 additions & 14 deletions source/styles/common/mixins/graphic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,10 @@
}
}

@mixin graphic-webp($filename, $extname: "jpg") {
$webp: url("../images/#{$filename}.webp");

@supports (background-image: $webp) {
background-image: $webp;
}

@supports not (background-image: $webp) {
background-image: url("../images/#{$filename}.#{$extname}");
}
}

@mixin graphic-retina($filename, $extname: "jpg") {
@include graphic-webp($filename, $extname);
background-image: url("../images/#{$filename}.webp");

@include media-retina {
@include graphic-webp("#{$filename}@2x", $extname);
background-image: url("../images/#{$filename}@2x.webp");
}
}

0 comments on commit 095e651

Please sign in to comment.