From 7fabc50f2c0e68780547fb63f642c1e3743b0ca4 Mon Sep 17 00:00:00 2001 From: Lyuboslav Alexandrov Date: Thu, 9 Mar 2023 17:32:28 +0200 Subject: [PATCH 1/3] Replaced the inline SVGO configuration with a config file that is compatible with SVGO@3 --- src/OptimizerChainFactory.php | 2 +- svgo.config.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 svgo.config.js diff --git a/src/OptimizerChainFactory.php b/src/OptimizerChainFactory.php index 20d6da0..889c068 100644 --- a/src/OptimizerChainFactory.php +++ b/src/OptimizerChainFactory.php @@ -42,7 +42,7 @@ public static function create(array $config = []): OptimizerChain ])) ->addOptimizer(new Svgo([ - '--disable={cleanupIDs,removeViewBox}', + '--config=svgo.config.js', ])) ->addOptimizer(new Gifsicle([ diff --git a/svgo.config.js b/svgo.config.js new file mode 100644 index 0000000..aba77c5 --- /dev/null +++ b/svgo.config.js @@ -0,0 +1,13 @@ +module.exports = { + plugins: [ + { + name: 'preset-default', + params: { + overrides: { + cleanupIDs: false, + removeViewBox: false, + }, + }, + }, + ], +}; \ No newline at end of file From eba092dcdc6db37181f394922d2c76715fc64cee Mon Sep 17 00:00:00 2001 From: Lyuboslav Alexandrov Date: Thu, 9 Mar 2023 17:32:34 +0200 Subject: [PATCH 2/3] Updated README.md --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 97acc33..04bdf8e 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Here's how to install all the optimizers on Ubuntu: sudo apt-get install jpegoptim sudo apt-get install optipng sudo apt-get install pngquant -sudo npm install -g svgo@1.3.2 +sudo npm install -g svgo sudo apt-get install gifsicle sudo apt-get install webp ``` @@ -71,7 +71,7 @@ And here's how to install the binaries on MacOS (using [Homebrew](https://brew.s brew install jpegoptim brew install optipng brew install pngquant -npm install -g svgo@1.3.2 +npm install -g svgo brew install gifsicle brew install webp ``` @@ -82,7 +82,7 @@ sudo dnf install epel-release sudo dnf install jpegoptim sudo dnf install optipng sudo dnf install pngquant -sudo npm install -g svgo@1.3.2 +sudo npm install -g svgo sudo dnf install gifsicle sudo dnf install libwebp-tools ``` @@ -106,12 +106,10 @@ PNGs will be made smaller by running them through two tools. The first one is [P ### SVGs -SVGs will be minified by [SVGO 1](https://github.com/svg/svgo). SVGO's default configuration will be used, with the omission of the `cleanupIDs` plugin because that one is known to cause troubles when displaying multiple optimized SVGs on one page. +SVGs will be minified by [SVGO](https://github.com/svg/svgo). SVGO's default configuration will be used, with the omission of the `cleanupIDs` and `removeViewBox` plugins because these are known to cause troubles when displaying multiple optimized SVGs on one page. Please be aware that SVGO can break your svg. You'll find more info on that in this [excellent blogpost](https://www.sarasoueidan.com/blog/svgo-tools/) by [Sara Soueidan](https://twitter.com/SaraSoueidan). -For now, the default configuration used for SVGO is only compatible with SVGO 1.x. To use options compatible with SVGO 2.x, you need to [create your own optimization chain](#creating-your-own-optimization-chains). - ### GIFs GIFs will be optimized by [Gifsicle](http://www.lcdf.org/gifsicle/). These options will be used: From c55eb4c02cef74c5485eb9889bf648b80e37eaf1 Mon Sep 17 00:00:00 2001 From: Lyuboslav Alexandrov Date: Thu, 9 Mar 2023 20:13:17 +0200 Subject: [PATCH 3/3] Adjusted svgo package version in the CI pipeline --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7437e7b..8b0aa15 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,7 +22,7 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y jpegoptim pngquant gifsicle optipng libjpeg-progs webp - sudo npm install -g svgo@1.3.2 + sudo npm install -g svgo - name: Setup PHP uses: shivammathur/setup-php@v2