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é : |
|
|
||
| module.exports = merge(common, { | ||
| mode: mode, | ||
| mode, |
There was a problem hiding this comment.
@firestar300 toujours ok cette modif ? au vu des derniers ajustements
|
|
||
| module.exports = merge(common, { | ||
| mode: mode, | ||
| mode, |
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 fc805ae. Configure here.
| ['gifsicle', { interlaced: true }], | ||
| ['jpegtran', { progressive: true }], | ||
| ['optipng', { optimizationLevel: 5 }], | ||
| ['svgo', { svgoconfig }], |
There was a problem hiding this comment.
SVGO config wrapped in extra object layer
Medium Severity
The svgoconfig variable (which exports { plugins: [...] }) is passed as { svgoconfig }, creating the object { svgoconfig: { plugins: [...] } } due to ES6 shorthand property syntax. The imagemin-svgo plugin expects the config object directly (e.g. { plugins: [...] }), so the custom SVGO settings are silently ignored and defaults are used instead. The correct usage is ['svgo', svgoconfig] without the wrapping braces.
Reviewed by Cursor Bugbot for commit fc805ae. Configure here.


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
Medium Risk
Touches the webpack production build pipeline (image minification and default image generation) and asset formats, which can change compiled output and potentially break image references if any paths/extensions are missed.
Overview
Switches default generated/static images from JPG to WebP:
WebpackImageSizesPluginnow generates defaults fromdefault.webpinwebpformat, and the login stylesheet points the logo tologo.webp.Moves image optimization to the production plugin stack by adding
image-minimizer-webpack-plugin(with imagemin + SVGO config) inconfig/plugins.jsand removing the previous optimizer wiring fromwebpack.common.js.Updates CI to use Corepack +
actions/setup-node@v4with Yarn caching, removes an unused SCSS mixin file, deletes an obsolete SVG asset, and bumpscaniuse-liteinyarn.lock.Reviewed by Cursor Bugbot for commit fc805ae. Bugbot is set up for automated code reviews on this repo. Configure here.