Linux command
svgo 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Optimize SVG
svgo [input.svg] -o [output.svg]
Optimize in place
svgo [file.svg]
Optimize directory
svgo -f [./icons] -o [./optimized]
Show file info
svgo [file.svg] --show-plugins
Use config file
svgo --config [svgo.config.js] [file.svg]
Disable plugin
svgo --disable=[removeViewBox] [file.svg]
Enable plugin
svgo --enable=[removeDimensions] [file.svg]
Pretty print output
svgo --pretty [file.svg]
说明
svgo (SVG Optimizer) is a Node.js-based tool for optimizing SVG files through a plugin architecture. Each plugin handles a specific optimization such as removing metadata, simplifying path data, merging redundant elements, cleaning up attributes, or removing empty containers. Plugins can be individually enabled or disabled through a configuration file or command-line flags, allowing fine-grained control over which optimizations are applied. The multipass option runs optimizations repeatedly until no further improvements are found. Folder mode batch-processes entire directories of SVG files. SVGO is widely used in front-end build pipelines and icon library workflows to minimize SVG file sizes before deployment. Pretty-print mode reformats output for readability when human-editable SVGs are needed.
参数
- -o, --output _FILE_
- Output file.
- -f, --folder _DIR_
- Input folder.
- --config _FILE_
- Config file.
- --disable _PLUGIN_
- Disable plugin.
- --enable _PLUGIN_
- Enable plugin.
- --pretty
- Pretty print.
- --multipass
- Multiple passes.
- -q, --quiet
- Quiet output.
FAQ
What is the svgo command used for?
svgo (SVG Optimizer) is a Node.js-based tool for optimizing SVG files through a plugin architecture. Each plugin handles a specific optimization such as removing metadata, simplifying path data, merging redundant elements, cleaning up attributes, or removing empty containers. Plugins can be individually enabled or disabled through a configuration file or command-line flags, allowing fine-grained control over which optimizations are applied. The multipass option runs optimizations repeatedly until no further improvements are found. Folder mode batch-processes entire directories of SVG files. SVGO is widely used in front-end build pipelines and icon library workflows to minimize SVG file sizes before deployment. Pretty-print mode reformats output for readability when human-editable SVGs are needed.
How do I run a basic svgo example?
Run `svgo [input.svg] -o [output.svg]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -o, --output _FILE_ do in svgo?
Output file.