svg / svgo

⚙️ Node.js tool for optimizing SVG files
https://svgo.dev/
MIT License
20.77k stars 1.38k forks source link

CLI option to disable plugins is no longer available #1356

Open JoKalliauer opened 3 years ago

JoKalliauer commented 3 years ago

I used an old version of SVGO like e.g. comand

svgo -i input.svg -o output.svg --pretty --indent=1 -p 3 --enable=removeHiddenElems --disable=removeUnknownsAndDefaults

and I got error: unknown option '--enable=removeHiddenElems'

However it seems svgo is not backwards compatible.

I have read #1329 and #1337/files, and do not understand what to do.

I have tried to copy svgo.config.js from https://github.com/svg/svgo/issues/1329#issuecomment-781585374 into the current folder and got

Error: Cannot find module 'svgo'
Require stack:
- /home/jkalliau/Documents/GitHub/cleanupSVG/svgo.config.js
- /home/jkalliau/prgm/node-v15.4.0-linux-x64/lib/node_modules/svgo/lib/svgo-node.js
- /home/jkalliau/prgm/node-v15.4.0-linux-x64/lib/node_modules/svgo/lib/svgo/coa.js
- /home/jkalliau/prgm/node-v15.4.0-linux-x64/lib/node_modules/svgo/bin/svgo
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/home/jkalliau/Documents/GitHub/cleanupSVG/svgo.config.js:3:34)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19)
TrySound commented 3 years ago

Hi. You need to install svgo locally like this npm i svgo

XhmikosR commented 3 years ago

@TrySound I'd say we need the CLI README.md examples to show how to disable/enable plugins too :)

TrySound commented 3 years ago

Only possible with config for now

adl commented 3 years ago

Came here for a similar reason: after my weekly update I had a lot of CI builds failing with error: unknown option '--disable=removeViewBox'.

The releases notes for 2.0.0 suggests that --disable/--enable might be reimplemented in a later version, so I'll simply stick to svgo@1.3.2 in the meantime. The amount of configuration needed in 2.0.0 to simply disable one plugin seems a bit overkill in my case.

evenfrost commented 3 years ago

Came here because of this as well. Looks like there is no way to use svgo if I just want to use it as a CLI program (without e.g. polluting local scope with node_modules created from npm i svgo). It's probably better to remove CLI usage at all then as it's so limited now.

DabeDotCom commented 3 years ago

Let me preface this by saying I do admire and appreciate the team's decision to, as a wise famous man once said: "Move Fast and Break Things"

However... I, too, was just bitten by the removal of the --enable=PLUGIN CLI argument. :-(

I would vote that this issue be reopened, lest people inadvertently start creating duplicates. (I almost did!)

JoKalliauer commented 3 years ago

I would like the reimplementation of --enable=PLUGIN-feature. (maybe I switch back to the buggy 1.3.2-version)

I had closed the issue, since I was able to solve the error, not meaning I'm anyhow happy with the solution/workaround.

Imho this bug-report/question is solved, but we should file a new feature-request. Since I do not know any duplicate/feature-request I reopen this issue for now, however it is up to the svgo-mebers how to proceed.