1- < img src = " https://raw.githubusercontent.com/scriptex/initial-commit/master/initial-commit.svg " alt = " Initial commit Logo " width = " 200 " />
1+ # SVGO Add viewBox [ ![ npm ] [ npm-version-img ]] [ npm-version-url ] [ ![ MIT license ] [ license-img ]] [ license-url ] [ ![ Twitter ] [ twitter-img ]] [ twitter-url ] [ ![ Analytics ] [ analytics-img ]] [ analytics-url ]
22
3- # Initial Commit [ ![ npm] [ npm-version-img ]] [ npm-version-url ] [ ![ MIT license] [ license-img ]] [ license-url ] [ ![ Twitter] [ twitter-img ]] [ twitter-url ] [ ![ Analytics] [ analytics-img ]] [ analytics-url ]
4-
5- > A starter template for a git repository.
3+ > An SVGO plugin to add ` viewBox ` attribute based on ` width ` and ` height ` attributes
64
75[ ![ All issues on Github] [ github-issues-img ]] [ github-issues-url ]
86[ ![ Open issues on Github] [ github-open-issues-img ]] [ github-open-issues-url ]
2321[ ![ Renovate App Status] [ renovateapp-img ]] [ renovateapp-url ]
2422[ ![ Make A Pull Request] [ prs-welcome-img ]] [ prs-welcome-url ]
2523
26- Use this when creating a NPM package, static website, or any other repository in a git environment
24+ This plugin adds the ` viewBox ` attribute to your SVGs based on the ` width ` and ` height ` attributes. The difference between this plugin and the built-in [ ` removeDimensions ` ] ( https://github.com/svg/svgo/blob/master/plugins/removeDimensions.js ) plugin is that ` svgo-add-viewbox ` does not remove the ` width ` and ` height ` of your SVGs.
25+
26+ In order to use this plugin correctly, you SVGs should have their ` width ` and ` height ` attributes specified.
2727
2828## Usage
2929
30- 1 . Clone this repository
31- 2 . Modify relevant files
32- 3 . Push to your new repository location
33- 4 . Profit
30+ ** This plugin should be used with SVGO v2 and above.**
31+
32+ 1 . Create a ` svgo.config.js ` file following the [ official configuration guide] ( https://github.com/svg/svgo#configuration )
33+ 2 . Use the option to specify a custom plugin.
34+ 3 . Install this module from NPM
35+ ``` sh
36+ npm install svgo-add-viewbox --save-dev
37+ # or
38+ yarn add svgo-add-viewbox -D
39+ ```
40+ 4. ` require` the module which you just created in your ` svgo.config.js` file:
41+ ` ` ` javascript
42+ const addViewBox = require(' svgo-add-viewbox' );
43+ ` ` `
44+ 5. In the ` plugins` array in your ` svgo.config.js` file add the following:
45+ ` ` ` javascript
46+ plugins: [
47+ // ... more plugins
48+ {
49+ fn: addViewBox.fn,
50+ name: ' addViewBox' ,
51+ type: addViewBox.type,
52+ active: addViewBox.active,
53+ description: addViewBox.description
54+ }
55+ // ... more plugins
56+ ];
57+ ` ` `
58+ 6. Execute your SVG transformation NPM script.
3459
3560# # Support this project
3661
@@ -45,33 +70,33 @@ Use this when creating a NPM package, static website, or any other repository in
4570
4671[MIT][license-url]
4772
48- [ npm-version-img ] : https://badgen.net/npm/v/webpack-mpa ?icon=npm
49- [ npm-version-url ] : https://www.npmjs.com/package/webpack-mpa
50- [ license-img ] : https://badgen.net/npm/license/webpack-mpa
51- [ license-url ] : https://github.com/scriptex/webpack-mpa /blob/master/LICENSE
73+ [npm-version-img]: https://badgen.net/npm/v/svgo-add-viewbox ? icon= npm
74+ [npm-version-url]: https://www.npmjs.com/package/svgo-add-viewbox
75+ [license-img]: https://badgen.net/npm/license/svgo-add-viewbox
76+ [license-url]: https://github.com/scriptex/svgo-add-viewbox /blob/master/LICENSE
5277[twitter-url]: https://twitter.com/scriptexbg
5378[twitter-img]: https://badgen.net/twitter/follow/scriptexbg? icon= twitter& color= 1da1f2& cache= 300
54- [ github-tag-img ] : https://badgen.net/github/tag/scriptex/webpack-mpa ?icon=github
55- [ github-tag-url ] : https://github.com/scriptex/webpack-mpa /releases/latest
56- [ github-checks-img ] : https://badgen.net/github/checks/scriptex/webpack-mpa ?icon=github
57- [ github-checks-url ] : https://github.com/scriptex/webpack-mpa
58- [ github-issues-img ] : https://badgen.net/github/issues/scriptex/webpack-mpa ?icon=github
59- [ github-issues-url ] : https://github.com/scriptex/webpack-mpa /issues
60- [ github-open-issues-img ] : https://badgen.net/github/open-issues/scriptex/webpack-mpa ?icon=github
61- [ github-open-issues-url ] : https://github.com/scriptex/webpack-mpa /issues?q=is%3Aopen+is%3Aissue
62- [ github-closed-issues-img ] : https://badgen.net/github/closed-issues/scriptex/webpack-mpa ?icon=github
63- [ github-closed-issues-url ] : https://github.com/scriptex/webpack-mpa /issues?q=is%3Aissue+is%3Aclosed
64- [ last-commit-img ] : https://badgen.net/github/last-commit/scriptex/webpack-mpa ?icon=github
65- [ last-commit-url ] : https://github.com/scriptex/webpack-mpa /commits/master
66- [ analytics-img ] : https://ga-beacon.appspot.com/UA-83446952-1/github.com/scriptex/webpack-mpa /README.md
67- [ analytics-url ] : https://github.com/scriptex/webpack-mpa /
68- [ npm-downloads-weekly-img ] : https://badgen.net/npm/dw/webpack-mpa ?icon=npm
69- [ npm-downloads-monthly-img ] : https://badgen.net/npm/dm/webpack-mpa ?icon=npm
70- [ npm-downloads-yearly-img ] : https://badgen.net/npm/dy/webpack-mpa ?icon=npm
71- [ npm-downloads-total-img ] : https://badgen.net/npm/dt/webpack-mpa ?icon=npm
72- [ npm-url ] : https://www.npmjs.com/package/webpack-mpa
79+ [github-tag-img]: https://badgen.net/github/tag/scriptex/svgo-add-viewbox ? icon= github
80+ [github-tag-url]: https://github.com/scriptex/svgo-add-viewbox /releases/latest
81+ [github-checks-img]: https://badgen.net/github/checks/scriptex/svgo-add-viewbox ? icon= github
82+ [github-checks-url]: https://github.com/scriptex/svgo-add-viewbox
83+ [github-issues-img]: https://badgen.net/github/issues/scriptex/svgo-add-viewbox ? icon= github
84+ [github-issues-url]: https://github.com/scriptex/svgo-add-viewbox /issues
85+ [github-open-issues-img]: https://badgen.net/github/open-issues/scriptex/svgo-add-viewbox ? icon= github
86+ [github-open-issues-url]: https://github.com/scriptex/svgo-add-viewbox /issues? q= is%3Aopen+is%3Aissue
87+ [github-closed-issues-img]: https://badgen.net/github/closed-issues/scriptex/svgo-add-viewbox ? icon= github
88+ [github-closed-issues-url]: https://github.com/scriptex/svgo-add-viewbox /issues? q= is%3Aissue+is%3Aclosed
89+ [last-commit-img]: https://badgen.net/github/last-commit/scriptex/svgo-add-viewbox ? icon= github
90+ [last-commit-url]: https://github.com/scriptex/svgo-add-viewbox /commits/master
91+ [analytics-img]: https://ga-beacon.appspot.com/UA-83446952-1/github.com/scriptex/svgo-add-viewbox /README.md
92+ [analytics-url]: https://github.com/scriptex/svgo-add-viewbox /
93+ [npm-downloads-weekly-img]: https://badgen.net/npm/dw/svgo-add-viewbox ? icon= npm
94+ [npm-downloads-monthly-img]: https://badgen.net/npm/dm/svgo-add-viewbox ? icon= npm
95+ [npm-downloads-yearly-img]: https://badgen.net/npm/dy/svgo-add-viewbox ? icon= npm
96+ [npm-downloads-total-img]: https://badgen.net/npm/dt/svgo-add-viewbox ? icon= npm
97+ [npm-url]: https://www.npmjs.com/package/svgo-add-viewbox
7398[tweet-img]: https://img.shields.io/badge/Tweet-Share_this_repository-blue.svg? style= flat-square& logo= twitter& color= 38A1F3
74- [ tweet-url ] : https://twitter.com/intent/tweet?text=Checkout%20this%20awesome%20software%20project%3A&url=https%3A%2F%2Fgithub.com%2Fscriptex%2Fwebpack-mpa &via=scriptexbg&hashtags=software%2Cgithub%2Ccode%2Cawesome
99+ [tweet-url]: https://twitter.com/intent/tweet? text= Checkout%20this%20awesome%20software%20project%3A& url= https%3A%2F%2Fgithub.com%2Fscriptex%2Fsvgo-add-viewbox & via= scriptexbg& hashtags= software%2Cgithub%2Ccode%2Cawesome
75100[paypal-img]: https://img.shields.io/badge/Donate-Support_me_on_PayPal-blue.svg? style= flat-square& logo= paypal& color= 222d65
76101[paypal-url]: https://www.paypal.me/scriptex
77102[patreon-img]: https://img.shields.io/badge/Become_Patron-Support_me_on_Patreon-blue.svg? style= flat-square& logo= patreon& color= e64413
@@ -81,13 +106,13 @@ Use this when creating a NPM package, static website, or any other repository in
81106[liberapay-img]: https://img.shields.io/liberapay/receives/scriptex.svg? logo= liberapay
82107[liberapay-url]: https://liberapay.com/scriptex
83108[issuehunt-img]: https://raw.githubusercontent.com/BoostIO/issuehunt-materials/master/v1/issuehunt-shield-v1.svg
84- [ issuehunt-url ] : https://issuehunt.io/r/scriptex/webpack-mpa
85- [ publish-size-img ] : https://badgen.net/packagephobia/publish/webpack-mpa
109+ [issuehunt-url]: https://issuehunt.io/r/scriptex/svgo-add-viewbox
110+ [publish-size-img]: https://badgen.net/packagephobia/publish/svgo-add-viewbox
86111[renovateapp-img]: https://badgen.net/badge/renovate/enabled/green? cache= 300
87112[renovateapp-url]: https://renovatebot.com
88113[prs-welcome-img]: https://badgen.net/badge/PRs/welcome/green? cache= 300
89- [ prs-welcome-url ] : https://github.com/scriptex/webpack-mpa /pulls
90- [ github-status-img ] : https://badgen.net/github/status/scriptex/webpack-mpa ?icon=github
91- [ github-status-url ] : https://github.com/scriptex/webpack-mpa /actions/workflows/build.yml
92- [ github-languages-img ] : https://img.shields.io/github/languages/count/scriptex/webpack-mpa
93- [ github-top-language-img ] : https://img.shields.io/github/languages/top/scriptex/webpack-mpa
114+ [prs-welcome-url]: https://github.com/scriptex/svgo-add-viewbox /pulls
115+ [github-status-img]: https://badgen.net/github/status/scriptex/svgo-add-viewbox ? icon= github
116+ [github-status-url]: https://github.com/scriptex/svgo-add-viewbox /actions/workflows/build.yml
117+ [github-languages-img]: https://img.shields.io/github/languages/count/scriptex/svgo-add-viewbox
118+ [github-top-language-img]: https://img.shields.io/github/languages/top/scriptex/svgo-add-viewbox
0 commit comments