GitHub release (opens new window) GitHub issues (opens new window) GitHub last commit (opens new window) Build Status (opens new window) npm (opens new window) npm (opens new window) Analytics (opens new window)

# svgo-viewBox

Add viewBox to SVG files using SVGO

Node JS script which uses SVGO and a custom plugin in order to add viewBox attribute to all SVG files in a folder.

# Dependencies

  1. NodeJS
  2. NPM or Yarn
  3. SVGO installed and configured - you should have an svgo.yml file. If you don't, the default config file will be used.
  4. Some SVG files which have width and height attribute but lack the viewBox attribute.

# Usage

svgo-viewbox --help

#	Usage
#	  $ svgo-viewbox --arg1 --arg2
#
#	Options
#	  --input, -i		path to folder which contains SVG files
#	  --svgo-file, -f 	path to SVGO configuration file in YAML format
#
#	Examples
#	  $ svgo-viewbox --input ./assets/images/svg --svgo-file ./svgo.yml
#     $ svgo-viewbox --i ./assets/images/svg

# As an NPM script:

First install the module as a development dependency

npm i svgo-viewbox --save-dev

# or

yarn add svgo-viewbox -D

then add a new NPM script in your package.json file:

{
	"scripts": {
		"svgo-viewbox": "svgo-viewbox -i ./assets/images/svg -f ./svgo.yml"
	}
}

# From the command line

First install the module globally

npm i -g svgo-viewbox

# or

yarn global add svgo-viewbox

then use it in your terminal

svgo-viewbox -i ./assets/images/svg -f ./svgo.yml

# Without installing

npx svgo-viewbox -i ./assets/images/svg -f ./svgo.yml

# Support this project

Tweet (opens new window) Donate (opens new window) Become a Patron (opens new window) Buy Me A Coffee (opens new window)

# LICENSE

MIT