{"name":"svg-url-loader","version":"2.2.0","description":"Converts SVG file to utf-8 encoded data-uri string","main":"src/index.js","scripts":{"test":"istanbul cover ./node_modules/.bin/_mocha -- test/*.spec.js","coverage":"cat coverage/*/lcov.info | codecov"},"dependencies":{"file-loader":"0.11.2","loader-utils":"1.1.0"},"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":"~2.3.0","css-loader":"0.28.7","expect.js":"~0.3.1","istanbul":"~0.4.5","less":"~2.7.2","less-loader":"~3.0.0","mocha":"~3.5.0","node-sass":"~4.5.0","object-assign":"~4.1.0","sass-loader":"~6.0.0","webpack":"~3.6.0"},"gitHead":"6194e4f774fddc651823ddd8cd2d516f8e73062c","_id":"svg-url-loader@2.2.0","_shasum":"107e02a3e5127c23e5a0a76ba32392df39f5ad98","_from":".","_npmVersion":"4.6.1","_nodeVersion":"6.9.1","_npmUser":{"name":"bhovhannes","email":"bhovhannes@gmail.com"},"dist":{"shasum":"107e02a3e5127c23e5a0a76ba32392df39f5ad98","tarball":"http://registry-npm.ywwl.com/svg-url-loader/download/svg-url-loader-2.2.0.tgz","integrity":"sha512-/2YtRBsekFDsonNWi0AEjFex8bcY9N2ncgw040mGvI8+JkDCz3fG4xsrJ+Y0s5/UyW5KBfpcd/L1QU06Cy4HDA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCRuMtnaBEGr1nYNpJt7uC5qm8oxQK94LNC6km1a6uJeQIgdv1s/51mRHwh7b13EIa3GRAz2godp1c6ycRS//EVer8="}],"size":6745,"noattachment":false,"key":"/svg-url-loader/-/svg-url-loader-2.2.0.tgz"},"maintainers":[{"name":"bhovhannes","email":"bhovhannes@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svg-url-loader-2.2.0.tgz_1506324576610_0.5688204399775714"},"directories":{},"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":1506324577458,"_cnpm_publish_time":1506324577458,"dist-tags":{"latest":"8.1.0"}}