{"name":"svg-url-loader","version":"3.0.2","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.2.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.2.0","jest":"24.9.0","less":"3.10.3","less-loader":"5.0.0","node-sass":"4.12.0","sass-loader":"8.0.0","webpack":"4.39.3"},"gitHead":"5e13f832905ba9e0b2bcc894600a1c980d2ee017","_id":"svg-url-loader@3.0.2","_nodeVersion":"10.15.3","_npmVersion":"6.11.2","dist":{"integrity":"sha512-MUJFVU2uuOTZW6Eq6NuXZxhaIyWiuKtZMcT90nCkcvIZPGGc0CYyZWYP/rtXUkja5qagNMpxDwdZ/tuC6ywfWg==","shasum":"7bcbb676927e71c9267fd879f8962396b59aa04a","tarball":"http://registry-npm.ywwl.com/svg-url-loader/download/svg-url-loader-3.0.2.tgz","fileCount":26,"unpackedSize":33516,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdb/pdCRA9TVsSAnZWagAAqzUP/iNiaGy1UdMe4x5MJpDQ\nqbUU/bvyJ5FqN0nKVbR4wLhNdsqW899/BQ07eHshIoGEJQCoMAFuZeZkoV3T\n7JEuMwWq4KFjnv6/ojvLlfDNZhsHvzlCEl59JumXb7tm+uH8KhBR5BBdvgQq\n0RsA95MUI4EmxheMrWVfESMrFopHf3BG7ko4g3APgpWZc1W0ouyqJvfhQR8N\ni3S5oIAYa7qnA+F0Q5odMfKg7YkjkwOn0a1bdmIumecTS6drVqzPvVwOcpPL\nLezk8T/JtfOzl+kNEcZElgiDFaozAQl6FKsLTplEo7P43dQYKG/DIxbExZde\nrQesMgC8HrCi7lM9CfRR81Pcb0z3YA8bjodBlAhCcPKq2+TlDweDBz6CWCTM\n6wvF6M72z8Ua9luOJua2T4ovmHEyQiCHAvp37HpYdwuk/NQUmIjwjF+mQWSC\nxZVJw7MFAibQLbuSlMOdgdNSwT3jjGDK2bhgmO58g7r3DQbnbqJiPtODbb6c\nqPANhHY6tIlO7dUKxyyl225DDdh+UINkGV0AYU11oz5RHqFGgSXzmN/s9d1A\nDjd2AAwKc4i+rQ/MpWlzJ4KpKJPgt/1xH/ePeaQdtnjEruewb5Vh1ZVZT5g8\nn/nU6LzPfuyPTwGVtvNv4vYEOzch7tRJMetJ0sont5yUFDUaqOUKPHRz1Yvt\nvCC1\r\n=7j6y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIArJU/kKoG9hWvumtugPMAFYbPPktxYHaV54Yx8kXVceAiATKsa8L52g0c1qIIV/FxHAXDjQ8V8/frB8QBYZb145EQ=="}],"size":6953,"noattachment":false,"key":"/svg-url-loader/-/svg-url-loader-3.0.2.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_3.0.2_1567619677206_0.3217595504658779"},"_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":1567619677312,"_cnpm_publish_time":1567619677312,"dist-tags":{"latest":"8.1.0"}}