Skip to content

Commit 43d99ce

Browse files
authored
Merge pull request #486 from BeAPI/feat/webp
Add WebP support and update dependencies
2 parents 61ea8fe + 440fb54 commit 43d99ce

13 files changed

Lines changed: 23 additions & 75 deletions

‎config/plugins.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ module.exports = {
4747
outputImageLocations: 'image-locations.json', // Output locations file name
4848
outputImageSizes: 'image-sizes.json', // Output sizes file name
4949
generateDefaultImages: true, // Generate default images
50-
defaultImageSource: 'src/img/static/default.jpg', // Source image for generation
50+
defaultImageSource: 'src/img/static/default.webp', // Source image for generation
5151
defaultImagesOutputDir: 'dist/images', // Default images output directory
52-
defaultImageFormat: 'jpg', // Generated image format (jpg, png, webp, avif)
52+
defaultImageFormat: 'webp', // Generated image format (jpg, png, webp, avif)
5353
silence: true, // Suppress console output
5454
}),
5555
new MiniCssExtractPlugin({

‎config/svgo.config.js‎

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
11
module.exports = {
22
plugins: [
3-
{ cleanupAttrs: true },
4-
{ removeDoctype: true },
5-
{ removeXMLProcInst: true },
6-
{ removeComments: true },
7-
{ removeMetadata: true },
8-
{ removeTitle: true },
9-
{ removeDesc: true },
10-
{ removeUselessDefs: true },
11-
{ removeEditorsNSData: true },
12-
{ removeEmptyAttrs: true },
13-
{ removeHiddenElems: true },
14-
{ removeEmptyText: true },
15-
{ removeEmptyContainers: true },
16-
{ cleanupEnableBackground: true },
17-
{ convertStyleToAttrs: true },
18-
{ convertColors: true },
19-
{ convertPathData: true },
20-
{ convertTransform: true },
21-
{ removeUnknownsAndDefaults: true },
22-
{ removeNonInheritableGroupAttrs: true },
23-
{ removeUselessStrokeAndFill: true },
24-
{ removeUnusedNS: true },
25-
{ cleanupIDs: true },
26-
{ cleanupNumericValues: true },
27-
{ moveElemsAttrsToGroup: true },
28-
{ moveGroupAttrsToElems: true },
29-
{ collapseGroups: true },
30-
{ removeRasterImages: false },
31-
{ mergePaths: true },
32-
{ convertShapeToPath: true },
33-
{ sortAttrs: true },
34-
{ removeDimensions: false },
35-
{ prefixIds: true },
36-
{ removeViewBox: false },
3+
{
4+
name: 'preset-default',
5+
params: {
6+
overrides: {
7+
// Disable a plugin included by default that you don't want (false)
8+
removeViewBox: false,
9+
},
10+
},
11+
},
12+
// Plugins that are not in the "preset-default" and that you want to activate
13+
'removeTitle',
14+
'convertStyleToAttrs',
15+
'prefixIds',
3716
],
3817
}

‎config/webpack-image-sizes-plugin.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class WebpackImageSizesPlugin {
4141
outputImageLocations: 'image-locations.json',
4242
outputImageSizes: 'image-sizes.json',
4343
generateDefaultImages: false,
44-
defaultImageSource: 'src/img/static/default.jpg',
44+
defaultImageSource: 'src/img/static/default.webp',
4545
defaultImagesOutputDir: 'dist/images',
46-
defaultImageFormat: 'jpg',
46+
defaultImageFormat: 'webp',
4747
silence: false,
4848
...options,
4949
}
@@ -543,8 +543,7 @@ class WebpackImageSizesPlugin {
543543

544544
this.log(
545545
'log',
546-
`🖼️ Processing ${sizeKeys.length} default images (${format.toUpperCase()}) from ${
547-
this.options.defaultImageSource
546+
`🖼️ Processing ${sizeKeys.length} default images (${format.toUpperCase()}) from ${this.options.defaultImageSource
548547
}`
549548
)
550549

‎config/webpack.common.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ module.exports = {
1818
minimizer: {
1919
implementation: ImageMinimizerPlugin.imageminMinify,
2020
options: {
21-
// Lossless optimization with custom option
22-
// Feel free to experiment with options for better result for you
2321
plugins: [
2422
['gifsicle', { interlaced: true }],
2523
['jpegtran', { progressive: true }],
2624
['optipng', { optimizationLevel: 5 }],
27-
// Svgo configuration here https://github.com/svg/svgo#configuratio
28-
['svgo', { svgoconfig }],
25+
['svgo', svgoconfig],
2926
],
3027
},
3128
},

‎config/webpack.dev.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const loaders = require('./loaders')
66
const mode = 'development'
77

88
module.exports = merge(common, {
9-
mode: mode,
9+
mode,
1010
stats: 'errors-only',
1111
devtool: 'inline-source-map',
1212
devServer: {

‎config/webpack.prod.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const loaders = require('./loaders')
55
const mode = 'production'
66

77
module.exports = merge(common, {
8-
mode: mode,
8+
mode,
99
stats: 'minimal',
1010
output: {
1111
filename: '[name].js',

‎src/img/static/default.jpg‎

-6.58 KB
Binary file not shown.

‎src/img/static/default.webp‎

3.84 KB
Loading

‎src/img/static/logo-beapi.svg‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/img/static/logo.jpg‎

-6.58 KB
Binary file not shown.

0 commit comments

Comments
 (0)