{"name":"rollup-plugin-smart-asset","version":"2.1.0","description":"Rollup plugin to rebase, inline or copy assets referenced from the code","keywords":["rollup-plugin","asset","rebase","url","copy","inline"],"main":"dist/rollup-plugin-smart-asset.cjs.js","jsnext:main":"dist/rollup-plugin-smart-asset.esm.js","module":"dist/rollup-plugin-smart-asset.esm.js","scripts":{"clean":"rimraf dist","eslint":"eslint 'src/**/*.js' '*.js'","eslint-fix":"eslint 'src/**/*.js' '*.js' --fix","jest":"jest","jest-watch":"jest --watch","rollup":"rollup -c","test":"npm run eslint && npm run jest","build":"npm run rollup","build-examples":"find examples -name rollup.config.js -exec echo - Building example: {} \\; -execdir rollup -c \\;","prepublishOnly":"npm run clean && npm run build"},"repository":{"type":"git","url":"git+https://github.com/sormy/rollup-plugin-smart-asset.git"},"author":{"name":"Artem Butusov","email":"art.sormy@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/sormy/rollup-plugin-smart-asset/issues"},"homepage":"https://github.com/sormy/rollup-plugin-smart-asset#readme","dependencies":{"big.js":"^5.2.2","magic-string":"^0.25.7","mime":"^2.4.6","mkdirp":"^1.0.4","rollup-pluginutils":"^2.8.2"},"devDependencies":{"@babel/core":"^7.11.1","@babel/preset-env":"^7.11.0","@babel/register":"^7.10.5","@rollup/plugin-babel":"^5.1.0","eslint":"^7.6.0","eslint-config-standard":"^14.1.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","jest":"^26.2.2","metrohash":"^2.6.0","rimraf":"^3.0.2","rollup":"^2.23.1","xxhash":"^0.3.0"},"peerDependencies":{"rollup":">0.60"},"gitHead":"a5bae6aad593d1d86334c906106968820b2a1ec6","_id":"rollup-plugin-smart-asset@2.1.0","_nodeVersion":"14.7.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-bv6gKl4GTwXRiMRrmlGU3nKMbC/qo0EQiRf+JQ644pm7BPx0cszWv2+SaHIqYze6aUhW/Q+Bo3gzNXVOSBAQGQ==","shasum":"8dd0d37862baabc8c9611e50466f3d9ecadea049","tarball":"http://registry-npm.ywwl.com/rollup-plugin-smart-asset/download/rollup-plugin-smart-asset-2.1.0.tgz","fileCount":5,"unpackedSize":41358,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMJ4OCRA9TVsSAnZWagAAy9wP/i/ruGWWDUHn3yANjRM/\nob1NowtK6iGmZ/Cb3+NB+VNvo2mLr6DySAzhO6hSFh8avtMP4DSCKuhyZH6I\nEJRXvalmyjnHWdFEXJTIGTlwVQCUeOtmrdVcWfKVkwbfDS7iXKF7WWv6TmeF\nGTrytqaFEgvpYBXv/TAShhaYOnA4WVOqoz+ychJI0uJW0Fd0WQ2CygeVpRc5\nLRWUIwvLZhwDz9w35F2vuley41C/I5Sb9Q4lz18B9mhHyADdInJkgbF7dGpL\npObTbaAJrFanDtSser1lKo2Rb+DuJ7AQb+plvtQrVNSWMpzjb47wG946XI+2\nlRS/8Ms9PtkKc2M8uNRdCm9VKx8qGqVFknGZetaLhriIM7qM2yH8gTv4rj+0\n510z/pEz5HQfjSHMq0/IowHrjpEgFfCCiB2lStuZoIb2eSs+dZyRXC3fomDN\nrc9XfYLP64TLHoDnrcq0uyvgf1R1XGebH5zn5czK4FNcsq4XybrIwYF7vjih\nzzdUAcrd0MrrmHG6Ql1mIIEJWMBTSjfPd25ecpP+cKvjwYBJA8ZhzwshvioL\njFasyvOvRiSD63DA7k1jE02Ic8STFN0XmzHEyqVihX4Uc4GvtVCJrmYrpaOu\nUuB/PfOA7JAhXyfwQ9hIPsFNYhyd0+qdjzW2s68zF2rQ64m4clZP4PPYjCVg\nWLkY\r\n=NZes\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBuwC2TjyHn4LJocdnZ8MTs16wc6XeUbErSAYbyYMdXLAiEAqEK7uS8JzZTr+5PPZsHl6jbODNZ+Dwt5+pKZ6BEbDzU="}],"size":8707,"noattachment":false,"key":"/rollup-plugin-smart-asset/-/rollup-plugin-smart-asset-2.1.0.tgz"},"maintainers":[{"name":"sormy","email":"art.sormy@gmail.com"}],"_npmUser":{"name":"sormy","email":"art.sormy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-smart-asset_2.1.0_1597021710379_0.18837260447490656"},"_hasShrinkwrap":false,"readme":"# Rollup Smart Asset Plugin\n\n## Overview\n\nRollup plugin to rebase, inline or copy assets referenced from the JavaScript code.\n\n## Usage\n\n```js\nimport smartAsset from \"rollup-plugin-smart-asset\"\n\nconst smartAssetOpts = { ... }\n\nexport default {\n  input: \"src/index.tsx\",\n  output: {\n    file: \"dist/index.js\",\n    format: \"iife\"\n  },\n  plugins: [\n    ...\n    smartAsset(smartAssetOpts)\n    ...\n  ]\n}\n```\n\n## Configuration\n\nFor libraries it is recommended to use `inline` or `copy` mode with `keepImport`\noption to delegate bundling to consumer's package bundler. Asset hashing is not\nneeded for this case and it is safe to set `useHash: false` and `keepName: true`.\n\nFor applications it is also recommended to use `inline` or `copy` mode with\nenabled by default hashing.\n\nDefault settings are set to be the same as in `postcss-smart-asset` to have one\nconfig for both of them.\n\nMain options:\n\n- `url`: Mode: `rebase` (default), `inline` and `copy`\n- `extensions`: What file extensions to process, defaults to\n  `[\".svg\", \".gif\", \".png\", \".jpg\"]` unless `exclude` or `include` are used.\n  This option is ignored if `include` or `exclude` options are used.\n- `include`: Micromatch pattern or array of micromatch patterns for files that\n  need to be processed by this plugin.\n- `exclude`: Micromatch pattern or array of micromatch patterns for files that\n  NOT need to be processed by this plugin.\n- `emitFiles`: Disable generating files if `false`, by default it's `true` -\n  useful when generating bundle for SSR.\n\nFor more details about `include` / `exclude` syntax please refer to:\n<https://github.com/micromatch/micromatch>\n\n## Mode: rebase\n\nRebase asset references to be relative to specific directory.\n\nOutput:\n\n```js\n// without keepImport (inside wrapper)\nexport default \"public_path_to_asset\"\n\n// with keepImport and cjs module format\nconst myAsset = require(\"relative_path_to_asset_from_bundle\")\n\n// with keepImport and esm module format\nimport myAsset from \"relative_path_to_asset_from_bundle\"\n```\n\nOptions:\n\n- `publicPath`: Reference file from JS using this path, relative to html page\n  where asset is referenced. Could be relative, absolute or CDN.\n- `rebasePath`: Rebase all asset urls to this directory, defaults to current directory.\n- `keepImport`: Keep import, so consumer of your package could define their own\n  bundle configuration.\n- `sourceMap`: Set to `true` to keep source map.\n\n## Mode: inline\n\nInline assets as base64 urls directly in source code.\n\nKeep in mind, all options for `copy` mode will be used if falled back to `copy` mode.\n\nOutput:\n\n```js\nexport default \"data:{mimeType};base64,{data}\"\n```\n\nOptions:\n\n- `maxSize`: Max file size to inline (in kb), fallback is `copy` mode,\n  defaults to `14` kbytes.\n\n## Mode: copy\n\nCopy asset to target directory and rebase original references to point to target path\ndepending on provided configuration.\n\nOutput:\n\n```js\n// without keepImport (inside wrapper)\nexport default \"public_path_to_asset\"\n\n// with keepImport and cjs module format\nconst myAsset = require(\"relative_path_to_asset_from_bundle\")\n// + file is copied to target directory\n\n// with keepImport and esm module format\nimport myAsset from \"relative_path_to_asset_from_bundle\"\n// + file is copied to target directory\n```\n\nOptions:\n\n- `publicPath`: Reference file from JS using this path, relative to html page\n  where asset is referenced. Could be relative, absolute or CDN.\n- `assetsPath`: Copy assets to this directory, relative to rollup output.\n- `useHash`: Enable to use `[hash][ext]` instead of default `[name][ext]`.\n- `keepName`: Use both hash and name `[name]~[hash][ext]` if `useHash` is `true`.\n- `nameFormat`: Use custom name format using these patterns `[name]`, `[ext]`,\n  `[hash]`.\n- `hashOptions`: Hash options.\n  - `hash`: Any valid Node's crypto hashing algorithm e.g. `sha1`, `md5` etc,\n    Hash-like class (see: https://nodejs.org/api/crypto.html#crypto_class_hash),\n    `metrohash64` or `metrohash128` if `metrohash` is installed,\n    `xxhash32` or `xxhash64` if `xxhash` is installed.\n    Default is `sha1`.\n  - `encoding`: Hash encoding `hex`, `base64` `base62`, `base58`, `base52`,\n    `base49`, `base36`, `base32`, `base26`. Default is `base52`.\n  - `maxLength`: Maximum length of returned digest. Keep in mind that\n    reducing it increases collison probability. Default is `8`.\n- `keepImport`: Keep import, so consumer of your package could define their own\n  bundle configuration.\n\n**Preserve Modules**\n\nRollup `preserveModules: true` is supported but additional context is required\nfor the plugin to properly detect rebased path to the asset.\n\nAdditional options needed:\n\n- `outputDir`: Path to output dir, should be the same as `output.dir`, can't be\n  automatically detected and neeed to be explicitly passed.\n- (optional) `preserveModules`: Set to `true` to activate mode, can be\n  automatically detected.\n- (optional) `inputFile`: Path to main entry, should be the same as `input.file`,\n  can be automatically detected. Object and array values for `input.file` are not\n  supported.\n\n## Migration\n\n### Migration from v1.x to v2.x\n\nChanges:\n\n- Option `hashOptions.hash` defaults to `sha1` instead of `metrohash128`.\n- Removed dependencies: `asset-hash`.\n- These dependencies are now optional: `xxhash` and `metrohash`.\n\nThe default configuration is changed in favor of default hash functions\nthat are available in NodeJS without requirement to build any native\nextensions during `npm install`.\n\nIf you would like to use ultra fast `metrohash64` or `metrohash128` hashes\nthen do `npm install metrohash` and set `hashOptions.hash` to `metrohash64`\nor `metrohash128`.\n\nIf you would like to use ultra fast `xxhash32` or `xxhash64` hashes\nthen do `npm install xxhash` and set `hashOptions.hash` to `xxhash32`\nor `xxhash64`.\n\n## Alternatives\n\n## @rollup/plugin-url (ex rollup-plugin-url)\n\n<https://github.com/rollup/rollup-plugin-url>\nor\n<https://github.com/rollup/plugins/tree/master/packages/url>\n\nThis Rollup plugin has fewer options, doesn't work if asset is already loaded\nby another plugin (by sourcemaps, for example) and doesn't have `keepImport`\nlike option (designed for applications).\n\n## postcss-smart-asset\n\n<https://github.com/sebastian-software/postcss-smart-asset>\n\nThis PostCSS plugin works for assets referenced from CSS, but doesn't work for\nassets imported from JavaScript.\n\n## rollup-plugin-rebase\n\n<https://github.com/sebastian-software/rollup-plugin-rebase>\n\nThis Rollup plugin is designed for libraries, has `keepImport` like option\nenabled by default so can't be used for applications.\n\n## Contribution\n\nPRs are very welcome!\n\n## License\n\nMIT\n","publish_time":1597021710479,"_cnpm_publish_time":1597021710479,"dist-tags":{"latest":"2.1.2"}}