{"name":"svg-url-loader","version":"3.0.1","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":"7.3.1","webpack":"4.39.2"},"gitHead":"4c107821cc9b8c4e2ba5db921801af23ac9b1c9d","_id":"svg-url-loader@3.0.1","_nodeVersion":"10.15.3","_npmVersion":"6.11.2","dist":{"integrity":"sha512-YNC31HokIawsbpqHY1tvjNli/VfgiJlfYR8pFjvJG+zzac11eLfU6q1xt6IhNOdHuuqJw2lsBbch8h99a0mOZA==","shasum":"3a74fd448c1f40d8f742520f33b7e29af1a99650","tarball":"http://registry-npm.ywwl.com/svg-url-loader/download/svg-url-loader-3.0.1.tgz","fileCount":26,"unpackedSize":33514,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdaUv8CRA9TVsSAnZWagAAGYwP/iXXyaQTDikKbOdrbFzC\neGxKpLV6VkjW41p00G1Ko36iutxNA6vANOIm5FJVFIvDfnaYyH6DqiGsb5hA\n0Xa/aj9AfbS5rtbXPb+7Lky8+yW7i4LYpFMuAXl2JpnhFKei38xN7HZlngFq\nYVdw2PcBitgtrm5dJhkIYAx9479Bvbt7hU/VErZjV54qeuz2yJp82+gRlMwp\nhaEINxvak8W9F9TK3eHlXBhaFOEzSiVtKEdR5tjfwhw8kA6upa2rNOTp0FOO\ndBQ2NTWY8vB7R/OMs5gjNRHxRnV95fJ5Lc2nLxmMiy78nMc3PU1jWYyINr0N\nW5s2+BrQsSGr1PI1/beRW7CQMeTcS++wvZ8O8l5ZI/xhJ5GWvcdHdfktARiD\nB+BvwjKGBY2kYB2NLFV7xNbYy/3vjN2takLmGmZqND4A9v/OxTEDtBNOQoSQ\nxBbAsb2dRqHxqf40FSA+g2xLlNXLfxxSpki2kt5dH0bmeHf2PZJY1X4GJLUF\nN8T3HjiRKeXtgdyJ9+BRsX0nGMHtde+5FwygZTlW09NQ9JLAh1jrMR/w7oA+\n5u3OlHipi6Nmbxfn82PQo0HLx8XL1pw279g140HCpXdsYJLL5SiMFeBKuhU4\nsJGqXR1GtYyG0nLa3YuXTCw32OwYNwQ8XEXAnlsiWYQpOH8JDIydR+oQtzMA\nVlj6\r\n=wERF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDpEJUOdnfRJZ3fCKlNbeCLCVtzCYdpmpigUAUTa1v5XwIgXd9YGHcnQGEskg8zlRVkB67ngYf53fRTxDgbO4jM01I="}],"size":6953,"noattachment":false,"key":"/svg-url-loader/-/svg-url-loader-3.0.1.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.1_1567181820012_0.94127281363413"},"_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":1567181820107,"_cnpm_publish_time":1567181820107,"dist-tags":{"latest":"8.1.0"}}