Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

feat: added webp webpack image converter #520

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
"bootstrap-italia": "1.3.9",
"classnames": "2.2.6",
"design-react-kit": "3.1.3",
"image-webpack-loader": "^8.1.0",
"react-dropzone": "11.0.1",
"react-google-recaptcha-v3": "1.7.0",
"react-select": "^4.3.1",
Expand Down
47 changes: 47 additions & 0 deletions razzle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,54 @@ module.exports = Object.assign({}, volto_config, {
],
};

const TO_WEBP_LOADER = {
test: /\.(gif|png|jpe?g)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
//bypassOnDebug: true, // webpack@1.x
//disable: true, // webpack@2.x and newer //

//Compress JPEG images
mozjpeg: {
progressive: true,
enabled: false,
},
//Compress PNG images
optipng: {
enabled: false,
},
//Compress PNG images
pngquant: {
quality: [0.65, 0.9],
speed: 4,
enabled: false,
},
//Compress SVG images
svgo: {
enabled: false,
},
//Compress GIF images
gifsicle: {
interlaced: false,
enabled: false,
},
//Compress JPG & PNG images into WEBP. The webp option will enable WEBP
webp: {
quality: 85,
enabled: true,
},
},
},
],
};

base_config.module.rules.push(SVG_LOADER);

base_config.module.rules.push(TO_WEBP_LOADER);

webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
...base_config.resolve.alias,
Expand All @@ -76,6 +122,7 @@ module.exports = Object.assign({}, volto_config, {
},
plugins: [
...(volto_config.plugins || {}),

{
name: 'scss',
options: {
Expand Down
5 changes: 3 additions & 2 deletions src/components/ItaliaTheme/Logo/Logo.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React from 'react';
import { Icon } from '@italia/components/ItaliaTheme';
import logo from './logo.png';

/*
* Customization with image
*
* If you have a jpg/png, do like this:
*
* <figure className="icon">
* <img src={logo} alt="" />
* <img src={logo} alt="" width="" height="" />
* </figure>
*
* Note the icon class.
*/

const Logo = () => <Icon color="" icon="it-pa" padding={false} size="" />;
const Logo = () => <img src={logo} className="icon" />; //<Icon color="" icon="it-pa" padding={false} size="" />;

export default Logo;
Binary file added src/components/ItaliaTheme/Logo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/ItaliaTheme/LogoFooter/LogoFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Icon } from '@italia/components/ItaliaTheme';
* If you have a jpg/png, do like this:
*
* <figure className="icon">
* <img src={logo} alt="" />
* <img src={logo} alt="" width="" height="" />
* </figure>
*
* Note the icon class.
Expand Down
Loading