Conversation
|
forcer la transformation de toutes les images en WebP |
|
tester |
- Added imagemin-webp to package.json and updated yarn.lock. - Configured WebP generation in webpack.common.js. - Updated SCSS files to support WebP images. - Removed obsolete logo SVG file.
Replace yarn set version berry with corepack enable to match packageManager and avoid lockfile v8→v9 migration blocked in PRs. Upgrade actions/setup-node to v4 with yarn cache.
…ate instance Move ImageMinimizerPlugin to plugins (generator + optional prod minifier) so ?as=webp works when minimization is off. Remove it from optimization.minimizer to keep a single instance and avoid asset name conflicts. Minor shorthand for mode in dev/prod config.
|
Vu avec @MarieComet Ne fonctionne pas pour les appels en PHP. Cette solution native webpack ne semble pas être le bon compromis. Il faudrait voir pour une alternative différente. TEST sur une autre branche pour pas poluer cette dernière : PR : #491
@firestar300 Bonne approche ou pas ? a dispo pour en discuter / tester |
- Introduced WebpackStaticImagesPlugin to copy and convert static images to WebP format. - Configured plugin in plugins.js with input and output directories, quality settings, and console output options.
Improve build performance by skipping image processing when no files in the input directory have changed. The plugin now registers the input directory as a context dependency and checks modified files during subsequent builds to avoid redundant processing.
…lugin Switch from Sharp to fs.copyFile for original assets to ensure they are preserved exactly as-is, maintaining source quality and metadata (EXIF/ICC). Sharp is now used exclusively for generating the WebP derivatives.
Add WebpackStaticImagesPlugin to handle static image processing
- Deleted unused JPEG images (default.jpg, logo.jpg) and replaced them with WebP versions (default.webp, logo.webp). - Updated SCSS and Webpack configuration to reference the new WebP images. - Removed imagemin-webp from package.json and yarn.lock as it is no longer needed. - Generate default images in webp format by default
- Deleted WebpackStaticImagesPlugin to streamline image processing. - Removed related configuration from plugins.js, eliminating the static image processing setup. - This change simplifies the build process by relying on existing image handling methods.
|
Pour faire suite au point entre TD :
TODO : A tester dans le cadre d'un projet, si ARI va bien aller charger les images webp générées, normalement oui au vu du json généré : |
|
TODO : tester sur un projet récent (CD78 et/ou VORTEX) |
Testé sur vortex, RAS ça fonctionne bien, les images par défaut de ARI pointent bien vers le fichier webp |
- Modified the SVGO configuration to align with SVGO 3 standards, replacing the old plugin format with the new preset-default structure. - Adjusted the plugins list in plugins.js to ensure proper integration of the updated svgoconfig. - This change enhances image optimization while maintaining compatibility with the latest SVGO version.
|
Retour du bugbot sur svgo fixé, cela cassait la compilation au build : #486 (comment) En regardant, en effet toute l'optimisation des svg n'était pas prise en compte car pas compatible avec la version 3 du package. Il a fallut migrer la configuration du format svgo 2 à 3 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit eb5e0fa. Configure here.
| }, | ||
| }, | ||
| }) | ||
| ) |
There was a problem hiding this comment.
ImageMinimizerPlugin moved from optimization.minimizer to plugins array
Medium Severity
ImageMinimizerPlugin with its minimizer config was moved from optimization.minimizer (in webpack.common.js) to the plugins array (in plugins.js). The PR description itself shows the correct pattern: the minimizer belongs in optimization.minimizer and only the generator belongs in plugins. Placing it in the plugins array bypasses webpack's optimization pipeline, losing caching and deduplication benefits. Community reports indicate this can cause significantly slower builds and high CPU usage with larger image sets. The plugin needs to be in optimization.minimizer — either back in webpack.common.js or in webpack.prod.js.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit eb5e0fa. Configure here.
There was a problem hiding this comment.
@firestar300 Le fait que t'as déplacé ça, le bugbot remonte ce soucis ? logique pour toi ?
- Included the 'removeTitle' plugin in the SVGO configuration to enhance SVG optimization by removing title elements from SVG files. - This addition aims to streamline SVG output and reduce file size.
|
@firestar300 traiter la dernière question de @cedric07 |
|
j'ai ajouté toute une partie compression explicite ici : https://github.com/wpcomvip/be-api-omnes-education/commit/36cc0c2d66003b49b235625688b0172321e19bdb#diff-bb4e9e7eafd203cca023dd3b159d9341c9a0cd17d08e1af3308cb5bb3bece53fR8-R41 pour inspiration/reprise et + considérer le passage à SVGo v4 ? |
The prefixIds plugin renames SVG symbol IDs during optimization, which breaks icon rendering: PHP references sprites via fixed hashes (e.g. #icon-facebook) in <use href="...">, and prefixed IDs no longer match those references. Removing the plugin restores stable symbol IDs and ensures icons display correctly in the sprite workflow.


Sur la base de cette doc : https://webpack.js.org/plugins/image-minimizer-webpack-plugin/#loader-generator-example-for-imagemin
Par défaut webpack va garder également le fichier non converti dans le dossier compilé.
Pour l'appel au fichier dans le code, il faut lui passer l'option
presetdu generator :?as=webpExemple :
background-image: url(../img/static/logo.jpg?as=webp)et Webpack viendra automatiquement convertir le fichier en webp et remplacer l'url :background-image: url(images/logo.webp)Exemple :
background-image: url(../img/static/logo.jpg)et Webpack ne fera pas la conversion et gardera le fichier jpg :background-image: url(images/logo.jpg)La conversion se fait au
yarn buildSi elle doit se faire aussi en mode dev, il faudrait déplacer le code au dessus :
Note
Low Risk
Changes are limited to build tooling, asset formats, and CI; no runtime auth or data paths. Risk is mainly verifying production builds still emit and reference images correctly after the WebP and minimizer moves.
Overview
Shifts static assets and generated placeholders to WebP by pointing the login logo and
WebpackImageSizesPlugindefaults atdefault.webp/logo.webpinstead of JPG, and drops the unusedbackground-staticretina mixin.Production image pipeline moves
ImageMinimizerPluginout of shared webpack config intoplugins.js(production only), wires SVGO through a slimmedpreset-defaultconfig (withremoveViewBoxkept), and removes the broken['svgo', { svgoconfig }]shape from common config. The standalonelogo-beapi.svgasset is cleared.CI enables Corepack before
actions/setup-node@v4with Yarn caching and drops the explicityarn set version berrystep.Reviewed by Cursor Bugbot for commit a169e0c. Bugbot is set up for automated code reviews on this repo. Configure here.