{"name":"svg-url-loader","version":"2.3.3","description":"Converts SVG file to utf-8 encoded data-uri string","main":"./index.js","scripts":{"test":"jest --coverage","test-watch":"jest --watch","coverage":"cat coverage/*/lcov.info | codecov"},"dependencies":{"file-loader":"4.0.0","loader-utils":"1.2.3"},"repository":{"type":"git","url":"git+https://github.com/bhovhannes/svg-url-loader.git"},"keywords":["data-uri","encoding","loader","svg","url-loader","utf8","webpack"],"author":{"name":"Hovhannes Babayan"},"license":"MIT","bugs":{"url":"https://github.com/bhovhannes/svg-url-loader/issues"},"homepage":"https://github.com/bhovhannes/svg-url-loader#readme","devDependencies":{"codecov":"3.5.0","css-loader":"3.0.0","jest":"24.8.0","less":"3.9.0","less-loader":"5.0.0","node-sass":"4.12.0","sass-loader":"7.1.0","webpack":"4.34.0"},"gitHead":"757cd4f49078066544eee8e40d002e7d96c15a2c","_id":"svg-url-loader@2.3.3","_nodeVersion":"10.15.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-dFXrXCrtyEucN6dWdvDGMipbVwPPez4OVVYUpxJwLJ5WuaPLYY9RmpOjUparDNs1+sPEXrsdDGIOCOK8NOy5VQ==","shasum":"4b111f6047472f815f9c1fd780c6faa413a8efab","tarball":"http://registry-npm.ywwl.com/svg-url-loader/download/svg-url-loader-2.3.3.tgz","fileCount":26,"unpackedSize":36004,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdBrRZCRA9TVsSAnZWagAAnLQQAIZRW5six2aGiaM2mckY\ngRwlTZBl6lhnd27wd+ukZCiechCTnvnNqvQ45EDWbrisn3DPyML0n5ftXIVL\n+Q8N3Isons4fp52rBbBRe8/5Ub7rMqBDMesc9cWqFee1j1Ru1kF0HIL7i6Dz\ny81a2LfoyxQh1QTjXWB/LLwC9o4jYXcd2hXPvIdHNz5fx6q+xc16b9zJKbRa\nedhBzg6dPWAut/ONcA8rAgAWMC63R+KvotP2t8pGXQjWUr4CNS+hWhy9/2O9\nKyJn/RdkTBim+Cz5/GuxY86Xdbft+cOynq4sd2KwlmZKkOKvIrUBDqY2CPYs\n+IPX9PN/pqQRxVmAJ66moFvT5eXSOyeuv2j5S80iKt15JGAlW/whhju6jeyz\nzJKXXerz1kSsxBZc5d/KlC01zfVCiCEZMuPNn/ryVyeDBwXDVReixkZo7dnW\niJRWL9AtmWoqwcpe/QdvAjBqx7nanlU89O+1WdGr3arRfEsE4Q8wqKaMnmmE\nqiEQtQsUHwCvGmE6dydNf5UMQzm4i86AbCa5bMyrEKNO7gAAILp9xervZ6Pt\nuvazp5WMtZrgpA8gh3a3gclnAEKyJw641i4BB7r3tyM3htX6XPXA1cVdl/oJ\ndJ97bPCsUWTzk2//05YZB88/zQpJr+X+7B4f35XELiN7KT+c1xiP4EtVobDs\nuq7s\r\n=qEz7\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD7qyhmQfG8B8A2Tn5ekMvwCfHHlLRiOgSgtzOhMg+C8gIhANvuh7B+q6ALiv9DiMGO2QacM+TrjqqLdqz0De0N8gOL"}],"size":7190,"noattachment":false,"key":"/svg-url-loader/-/svg-url-loader-2.3.3.tgz"},"maintainers":[{"name":"bhovhannes","email":"bhovhannes@gmail.com"}],"_npmUser":{"name":"bhovhannes","email":"bhovhannes@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svg-url-loader_2.3.3_1560720473270_0.3063514085795662"},"_hasShrinkwrap":false,"readme":"# svg-url-loader\n\n[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![codecov][codecov-image]][codecov-url] [![MIT License][license-image]][license-url]\n\nA webpack loader which loads SVG file as utf-8 encoded DataUrl string.\n\nExisting [`url-loader`](https://github.com/webpack-contrib/url-loader) always does Base64 encoding for data-uri. As SVG content is a human-readable xml string, using base64 encoding is not mandatory. Instead, one may only escape [unsafe characters](http://www.ietf.org/rfc/rfc1738.txt) and replace `\"` with `'` as described [in this article](http://codepen.io/Tigt/post/optimizing-svgs-in-data-uris).\n\nThere are some benefits for choosing utf-8 encoding over base64.\n\n1. Resulting string is shorter (can be ~2 times shorter for 2K-sized icons);\n2. Resulting string will be compressed better when using gzip compression;\n3. Browser parses utf-8 encoded string faster than its base64 equivalent.\n\n## Supported parameters\n\nParameters can be passed both in an url or from webpack config file. See [Loaders](https://webpack.js.org/concepts/loaders/) section in webpack documentation for more details.\n\nPassing parameters using `resourceQuery` is also supported:\n\n```css\n.selector {\n  background-image: url(../assets/foo.svg?encoding=base64);\n}\n```\n\nThe loader supports the following parameters:\n\n### `limit`\n\nIf given, loader will not encode the source file if its content is greater than this limit.\nDefaults to no limit.\nIf the file is greater than the limit the [`file-loader`](https://github.com/webpack-contrib/file-loader) is used, receiving all query parameters set for svg-url-loader.\n\n```javascript\nrequire(\"svg-url-loader?limit=1024!./file.svg\");\n// => DataUrl if \"file.png\" is smaller that 1kb\n\nrequire(\"svg-url-loader?prefix=img/!./file.svg\");\n// => Parameters for the file-loader are valid too\n//    They are passed to the file-loader if used.\n```\n\n### `stripdeclarations`\n\nThis option is true by default. **It will be removed in the next major release.**  \nSee [this issue](https://github.com/bhovhannes/svg-url-loader/issues/104#issuecomment-348377933) for more context about this decision.\n\nIf given will tell the loader to strip out any XML declaration, e.g. `<?xml version=\"1.0\" encoding=\"UTF-8\"?>` at the beginning of imported SVGs.\nInternet Explorer (tested in Edge 14) cannot handle XML declarations in CSS data URLs (`content: url(\"data:image/svg...\")`).\n\n```javascript\nrequire(\"svg-url-loader?stripdeclarations!./file.svg\");\n```\n\n### `iesafe`\n\nThis option tells loader to fall back to the file-loader if the file contains a style-element and the encoded size is above 4kB no matter the `limit` specified.\n\nThis option was introduced because Internet Explorer (including IE11) stops parsing style-elements in SVG data-URIs longer than 4kB. This results in black fill-color for all styled shapes.\n\nYou can either specify `iesafe` option in the query:\n\n```javascript\n// apply `iesafe` option only for 'foo.svg'\nrequire(\"svg-url-loader?iesafe!./foo.svg\");\n```\n\nOr, you can set this option globally in you webpack config:\n\n```javascript\nmodule.exports = {\n  //...\n  module: {\n    rules: [\n      {\n        test: /\\.svg/,\n        use: {\n          loader: \"svg-url-loader\",\n          options: {\n            // make all svg images to work in IE\n            iesafe: true,\n          },\n        },\n      },\n    ],\n  },\n  //...\n};\n```\n\n### `encoding`\n\nThis option controls which encoding to use when constructing a data-URI for an SVG. When set to a non-\"none\" value, loader does not apply quotes to the resulting data-URI.\n\nPossible values are \"base64\" and \"none\". Defaults to \"none\".\n\nNormally, setting `encoding` option to `base64` _should not_ be required, as using base64 encoding defeats the original purpose of this loader - embed svg with minimal size overhead. However, because of incompatibility with some tools, we support this mode, too.\n\nYou can either specify `base64` option in the query:\n\n```javascript\n// apply `base64` option only for 'foo.svg'\nrequire(\"svg-url-loader?encoding=base64!./foo.svg\");\n```\n\nOr, you can set this option globally in you webpack config:\n\n```javascript\nmodule.exports = {\n  //...\n  module: {\n    rules: [\n      {\n        test: /\\.svg/,\n        use: {\n          loader: \"svg-url-loader\",\n          options: {\n            // make loader to behave like url-loader, for all svg files\n            encoding: \"base64\",\n          },\n        },\n      },\n    ],\n  },\n  //...\n};\n```\n\n## Usage\n\n[Documentation: Loaders](https://webpack.js.org/concepts/loaders/)\n\n### In JS:\n\n```javascript\nrequire(\"svg-url-loader!./file.svg\");\n// => DataUrl for file.svg\n```\n\n### In CSS (with webpack.config.js below):\n\n```css\n.icon {\n  background: url(\"../images/file.svg\");\n}\n```\n\n```javascript\nmodule.exports = {\n  //...\n  module: {\n    rules: [\n      {\n        test: /\\.svg/,\n        use: {\n          loader: \"svg-url-loader\",\n          options: {},\n        },\n      },\n    ],\n  },\n  //...\n};\n```\n\n## Benefits of using data-uri\n\n1. Browser won't make an extra http call to download the image\n2. Some folks [mentioned](https://github.com/bhovhannes/svg-url-loader/issues/341) that even if image is in browser cache images with data url appear on screen faster.\n\n## License\n\nMIT (http://www.opensource.org/licenses/mit-license.php)\n\n[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square\n[license-url]: LICENSE\n[npm-url]: https://www.npmjs.org/package/svg-url-loader\n[npm-version-image]: https://img.shields.io/npm/v/svg-url-loader.svg?style=flat-square\n[npm-downloads-image]: https://img.shields.io/npm/dm/svg-url-loader.svg?style=flat-square\n[codecov-url]: https://codecov.io/gh/bhovhannes/svg-url-loader\n[codecov-image]: https://codecov.io/gh/bhovhannes/svg-url-loader/branch/master/graph/badge.svg?token=iJvUUKrgzB\n","publish_time":1560720473418,"_cnpm_publish_time":1560720473418,"dist-tags":{"latest":"8.1.0"}}