{"name":"postcss-url","version":"7.3.0","description":"PostCSS plugin to rebase or inline on url().","keywords":["css","postcss","postcss-plugin","url","rebase","inline","base64","assets"],"author":{"name":"Maxime Thirouin"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/postcss/postcss-url.git"},"main":"src/index.js","files":["src"],"dependencies":{"mime":"^1.4.1","minimatch":"^3.0.4","mkdirp":"^0.5.0","postcss":"^6.0.1","xxhashjs":"^0.2.1"},"devDependencies":{"chai":"^3.5.0","eslint":"^3.16.1","mocha":"^3.2.0","npmpub":"^3.0.1","postcss-import":"^10.0.0"},"scripts":{"lint":"eslint --fix .","tests":"mocha","test":"npm run lint && npm run tests","release":"npmpub"},"gitHead":"953ba4b0c70d86131c2c682c9b9e59e2103c177b","bugs":{"url":"https://github.com/postcss/postcss-url/issues"},"homepage":"https://github.com/postcss/postcss-url#readme","_id":"postcss-url@7.3.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"sergcen","email":"sergcen@mail.ru"},"dist":{"integrity":"sha512-VBP6uf6iL3AZra23nkPkOEkS/5azj1xf/toRrjfkolfFEgg9Gyzg9UhJZeIsz12EGKZTNVeGbPa2XtaZm/iZvg==","shasum":"cf2f45e06743cf43cfea25309f81cbc003dc783f","tarball":"http://registry-npm.ywwl.com/postcss-url/download/postcss-url-7.3.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC0SgE34tnPR8aBRnLxAEne4y5bD3SDPJ9/gwLiBtgjZAIhAKc0A1K9HVmf2sVdqKl9rS3oe20OrlVyDN2jyS6fKa5F"}],"size":13588,"noattachment":false,"key":"/postcss-url/-/postcss-url-7.3.0.tgz"},"maintainers":[{"name":"sergcen","email":"sergcen@mail.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postcss-url-7.3.0.tgz_1511646774862_0.19256188138388097"},"directories":{},"readme":"# postcss-url\n\n[![Travis Build Status](https://img.shields.io/travis/postcss/postcss-url/master.svg?label=unix%20build)](https://travis-ci.org/postcss/postcss-url)\n[![AppVeyor Build Status](https://img.shields.io/appveyor/ci/MoOx/postcss-url/master.svg?label=windows%20build)](https://ci.appveyor.com/project/MoOx/postcss-url)\n[![dependencies Status](https://david-dm.org/postcss/postcss-url/status.svg)](https://david-dm.org/postcss/postcss-url)\n[![devDependencies Status](https://david-dm.org/postcss/postcss-url/dev-status.svg)](https://david-dm.org/postcss/postcss-url?type=dev)\n\n> [PostCSS](https://github.com/postcss/postcss) plugin to rebase, inline or copy on url().\n\n## Installation\n\n```console\n$ npm install postcss postcss-url\n```\n\n## Basic example - rebase\n\n```js\n// dependencies\nconst fs = require(\"fs\")\nconst postcss = require(\"postcss\")\nconst url = require(\"postcss-url\")\n\n// css to be processed\nconst css = fs.readFileSync(\"input.css\", \"utf8\")\n\n// process css\nconst output = postcss()\n  .use(url({\n    url: \"rebase\"\n  }))\n  .process(css, {\n    from: \"src/stylesheet/index.css\",\n    to: \"dist/index.css\"\n  })\n```\nbefore:\n```css\n.element {\n    background: url('images/sprite.png');\n}\n```\nafter:\n```css\n.element {\n    /* rebasing path by new destination */\n    background: url('../src/stylesheet/images/sprite.png');\n}\n```\n\n\n## Inline\n```js\n// postcss-url options\nconst options = {\n    url: 'inline'\n};\n\npostcss()\n  .use(url(options))\n  .process(css, {\n    from: \"src/stylesheet/index.css\",\n    to: \"dist/index.css\"\n  })\n```\nbefore:\n```css\n.element {\n    background: url('/images/sprite.png');\n    filter: url('/images/circle.svg');\n}\n```\nafter:\n```css\n.element {\n    /* inlined png as base64 */\n    background: url('data:image/png;base64,R0lGODlhAQABAJH/AP///wAAAP///wAAACH/C0FET0JFOklSMS4');\n    /* inlined svg as encodeURIComponent */\n    filter: url('data:image/svg+xml,%3Csvg xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%2F%3E');\n}\n```\n\n## Copy\n```js\n// postcss-url options\nconst options = {\n    url: 'copy',\n    // base path to search assets from\n    basePath: path.resolve('node_modules/bootstrap'),\n    // dir to copy assets\n    assetsPath: 'img',\n    // using hash names for assets (generates from asset content)\n    useHash: true\n};\n\npostcss()\n  .use(url(options))\n  .process(css, {\n    from: \"src/stylesheet/index.css\",\n    to: \"dist/index.css\"\n  })\n```\nbefore:\n```css\n.element {\n    background: url('/images/sprite.png');\n}\n```\nafter:\n```css\n.element {\n    /* copy 'sprite.png' from 'node_modules/bootstrap/images/' to 'dist/img/' */\n    /* and rename it by hash function */\n    background: url('img/a2ds3kfu.png');\n}\n```\n\n### Multiple options\n\nprocess first matched option by default.\n```multi: true``` in `custom` will processing with other options\n\n```js\nconst options = [\n    { filter: '**/assets/copy/*.png', url: 'copy', assetsPath: 'img', useHash: true },\n    { filter: '**/assets/inline/*.svg', url: 'inline' },\n    { filter: '**/assets/**/*.gif', url: 'rebase' },\n    // using custom function to build url\n    { filter: 'cdn/**/*', url: (asset) => `https://cdn.url/${asset.url}` }\n];\n\npostcss().use(url(options))\n```\n\nCheckout [tests](test) for examples.\n\n### Options combinations\n\n* `rebase` - _default_\n  * `assetsPath` - directory to copy assets (relative to `to` or absolute)\n* `inline`\n  * `basePath` - path or array of paths to search assets (relative to `from`, or absolute)\n  * `encodeType` - `base64`, `encodeURI`, `encodeURIComponent`\n  * `includeUriFragment` - include the fragment identifer at the end of the URI\n  * `maxSize` - file size in kbytes\n  * `fallback` - `copy`, `rebase` or custom function for files > `maxSize`\n  * `ignoreFragmentWarning` - do not warn when an SVG URL with a fragment is inlined\n  * `optimizeSvgEncode` - reduce size of inlined svg (IE9+, Android 3+)\n* `copy`\n    * `basePath` - path or array of paths to search assets (relative to `from`, or absolute)\n    * `assetsPath` - directory to copy assets (relative to `to` or absolute)\n    * `useHash` - use filehash(xxhash) for naming\n    * `hashOptions` - options for hash function\n* `custom {Function}`\n    * `multi` - processing with other options\n\n### Options list\n\n#### `url`\n##### `rebase` - _(default)_\nAllow you to fix `url()` according to postcss `to` and/or `from` options (rebase to `to` first if available, otherwise `from` or `process.cwd()`).\n##### `inline` \nAllow you to inline assets using base64 encoding. Can use postcss `from` option to find ressources.\n##### `copy`\nAllow you to copy and rebase assets according to postcss `to`, `assetsPath` and `from` options (`assetsPath` is relative to the option `to`).\n##### `url: {Function}`\nCustom transform function. Takes following arguments:\n* `asset`\n  * `url` - original url\n  * `pathname` - url pathname (url without search or hash)\n  * `absolutePath` - absolute path to asset\n  * `relativePath` - current relative path to asset\n  * `search` - _search_ from `url`, ex. `?query=1` from `./image.png?query=1`\n  * `hash` - _hash_ from `url`, ex. `#spriteLink` from `../asset.svg#spriteLink`\n* `dir`\n  * `from` - postcss option from\n  * `to` - postcss option to\n  * `file` - decl file path\n* `options` - postcss-url matched options\n* `decl` - related postcss declaration object\n* `warn` - wrapped function `result.warn` for current `decl`\n* `result` – postcss result object\n\nAnd should return the transformed url.\nYou can use this option to adjust urls for CDN.\n\n#### `maxSize`\n\nSpecify the maximum file size to inline (in kbytes)\n\n#### `ignoreFragmentWarning`\n_(default: `false`)_\n\nDo not warn when an SVG URL with a fragment is inlined.\nPostCSS-URL does not support partial inlining.  The entire SVG file will be inlined.  By default a warning will be issued when this occurs.\n\n**NOTE:** Only files less than the maximum size will be inlined.\n\n#### `filter`\n\nA regular expression e.g. `/\\.svg$/`, a [minimatch string](https://github.com/isaacs/minimatch) e.g. `'**/*.svg'` or a custom filter function to determine wether a file should be inlined.\n\n#### `fallback`\n\nThe url fallback method to use if max size is exceeded or url contains a hash.\nCustom transform functions are supported.\n\n#### `includeUriFragment`\n_(default: `false`)_\n\nSpecifies whether the URL's fragment identifer value, if present, will be added\nto the inlined data URI.\n\n#### `basePath`\n\nSpecify the base path or list of base paths where to search images from\n\n#### `assetsPath`\n\n_(default: `false`)_\n\nIf you specify an `assetsPath`, the assets files will be copied in that\ndestination\n\n#### `useHash`\n\n_(default: `false`)_\n\nIf set to `true` the copy method is going to rename the path of the files by a hash name\n\n#### `hashOptions`\n\n##### `method`\n\n_(default: `xxhash32`)_\n\nHash method `xxhash32|xxhash64` or custom function (accept file buffer)\n##### `shrink`\n\n_(default: `8`)_\n\nResult hash shrink count\n##### `append`\n\n_(default: `false`)_\n\nPrepend the original filename in resulting filename\n\n---\n\n## Contributing\n\nWork on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.\n\n```console\n$ git clone https://github.com/postcss/postcss-url.git\n$ git checkout -b patch-1\n$ npm install\n$ npm test\n```\n\n## [Changelog](CHANGELOG.md)\n\n## [License](LICENSE)\n","publish_time":1511646775915,"_cnpm_publish_time":1511646775915,"dist-tags":{"beta":"9.0.0","latest":"10.1.4"}}