Repository navigation
Build icons as plain SVG - #519
Open
firestar300 wants to merge 2 commits into
Open
firestar300 wants to merge 2 commits into
firestar300 wants to merge 2 commits into
Conversation
…ed as sprite or plain svg
cedric07
reviewed
Oct 9, 2026
Comment on lines
-5
to
-10
| params: { | ||
| overrides: { | ||
| // Disable a plugin included by default that you don't want (false) | ||
| removeViewBox: false, | ||
| }, | ||
| }, |
Contributor
There was a problem hiding this comment.
C'est volontaire ?
Sur le svg généré, il n'y aura plus de viewbox. De mémoire ça posait des soucis de taille.
Contributor
There was a problem hiding this comment.
Je suis passé à SVGO 4 sur cette PR : https://github.com/BeAPI/beapi-frontend-framework/pull/518/changes
Et avait justement remanié le fichier pour éviter le warning, car la structure change. Il faut le mettre dans le tableau en dessous
| * @return string | ||
| */ | ||
| function get_the_icon( string $icon_class, $additionnal_classes = [] ): string { | ||
| function get_the_icon( string $icon_class, $additionnal_classes = [], bool $is_sprite = true ): string { |
Contributor
There was a problem hiding this comment.
On part du principe qu'on utilise toujours des sprite par défaut ? pas l'inverse ?
| * @return string | ||
| */ | ||
| public function get_the_icon( string $icon_class, array $additionnal_classes = [] ): string { | ||
| public function get_the_icon( string $icon_class, array $additionnal_classes = [], bool $is_sprite = true ): string { |
| "stylelint-scss": "^6.14.0", | ||
| "stylelint-webpack-plugin": "^5.1.0", | ||
| "svg-sprite-loader": "^6.0.11", | ||
| "svgo": "^4.0.2", |
Contributor
There was a problem hiding this comment.
#518 j'avais migé ici déjà, est-ce que ça vaut le coup de merger cette PR et rebase dans ta branche ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cette PR enrichit la chaîne de build et l’affichage des icônes SVG du thème :
dist/icons/, chaque SVG source soussrc/img/icons/est optimisé (SVGO) et copié dansdist/images/en conservant l’arborescence (sprite/,social/, etc.).get_the_icon()/the_icon()acceptent un 3ᵉ paramètre$is_sprite(défauttrue) pour choisir entre référence sprite (<use>) et SVG fichier inline.removeViewBoxobsolète qui provoquait un warning au build).Le comportement existant (sprites + cache-busting via
sprite-hashes.asset.php) reste inchangé par défaut.Changements techniques
config/webpack-icon-files-plugin.jsafterEmit) : lecturesrc/img/icons/**/*.svg→ écrituredist/images/**avecconfig/svgo.config.jsconfig/plugins.jsconfig/svgo.config.jspackage.jsonsvgo(utilisée par le plugin)inc/Services/Svg.php$is_sprite, parsing d’identifiant, chargement sécurisé du fichier, injection des classes sur la balise<svg>racineinc/Helpers/Svg.php$is_spriteExemples d’usage
Chemins générés côté build, par exemple :
src/img/icons/sprite/menu.svg→dist/icons/sprite.svg(sprite) etdist/images/sprite/menu.svg(fichier)src/img/icons/social/facebook.svg→dist/icons/social.svgetdist/images/social/facebook.svgTest plan
npm run buildsans erreur (vérifier l’absence du warning SVGOremoveViewBox)dist/icons/sprite.svg,dist/icons/social.svgdist/images/sprite/*.svg,dist/images/social/*.svgthe_icon( 'share' ), partage d’article, etc.) inchangées visuellementthe_icon( 'menu', [], false )— markup SVG complet dans le HTML, classesicon/icon-menuprésentesget_the_icon( 'social/facebook', [], false )— fichierdist/images/social/facebook.svgbien serviNotes
dist/images/(artefacts de build du thème) ; le chemin est validé viarealpathsousdist/images.svgo-loaderpour les sprites, plugin dédié pour les fichiers unitaires,imagemin-svgodans la minification d’images).