Code Monkey home page Code Monkey logo

svgo-viewbox's Introduction

GitHub release GitHub issues GitHub last commit Build Status npm npm Analytics

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 or to a single SVG file.

Dependencies

  1. NodeJS
  2. NPM or Yarn
  3. SVGO installed and configured - you should have a svgo.config.js 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 or a single svg file, defaults to current working directory
#       --svgo-file, -f     path to SVGO configuration file in JS format (https://github.com/svg/svgo#configuration), defaults to the built-in SVGO configuration
#
#   Examples
#       $ svgo-viewbox --input ./assets/images/svg --svgo-file ./svgo.config.js
#       $ svgo-viewbox -i ./assets/images/svg
#       $ svgo-viewbox -i ./assets/images/svg/file.svg
#       $ svgo-viewbox

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.config.js"
	}
}

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.config.js

Without installing

npx svgo-viewbox -i ./assets/images/svg -f ./svgo.config.js

LICENSE

MIT


Connect with me:

                     

Support and sponsor my work:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.