{"id":14385063,"url":"https://github.com/mattdesl/urify","last_synced_at":"2025-07-18T06:37:14.083Z","repository":{"id":21771142,"uuid":"25093385","full_name":"mattdesl/urify","owner":"mattdesl","description":"inlines datauri expressions into your bundle","archived":false,"fork":false,"pushed_at":"2018-08-08T13:52:20.000Z","size":1979,"stargazers_count":23,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-05T23:36:50.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattdesl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-11T20:03:27.000Z","updated_at":"2024-02-24T00:25:58.000Z","dependencies_parsed_at":"2022-08-19T16:50:32.343Z","dependency_job_id":null,"html_url":"https://github.com/mattdesl/urify","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/mattdesl/urify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Furify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Furify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Furify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Furify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattdesl","download_url":"https://codeload.github.com/mattdesl/urify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattdesl%2Furify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265711365,"owners_count":23815520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-28T18:01:55.002Z","updated_at":"2025-07-18T06:37:14.043Z","avatar_url":"https://github.com/mattdesl.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# urify\n\n[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n\nA simple module to synchronously return a DataURI for the given file path.\n\nThis also includes a browserify transform to statically analyze the expression, inlining the URI during the bundle step. This allows you to do the following in the browser:\n\n```js\nvar path = require('path');\nvar urify = require('urify');\nvar uri = urify(path.join(__dirname, 'icon.png'));\n\nvar img = new Image()\nimg.onload = function() {\n  console.log(\"Image loaded!\")\n}\nimg.src = uri\n```\n\nWhile bundling, include the `urify/transform` like so:\n\n```browserify -t urify/transform foo.js \u003e bundle.js```\n\nAfter bundling, the code will look like this:\n\n```js\nvar uri = \"data:image/png;base64,.....\"\n\nvar img = new Image()\nimg.onload = function() {\n  console.log(\"Image loaded!\")\n}\nimg.src = uri\n```\n\n## API Usage\n\n[![NPM](https://nodei.co/npm/urify.png)](https://nodei.co/npm/urify/)\n\n### `urify = require('urify')`\n#### `uri = urify(file)`\n\nSynchronously grabs a file's DataURI string, with the following format:\n\n```js\n\"data:image/png;base64,.....\"\n```\n\n### `transform = require('urify/transform')`\n#### `stream = transform(file, [opts])`\n\nReturns a through stream inlining `require('urify')` calls to their statically evaluated DataURI strings. \n\nOptionally, you can set which `opt.vars` will be used in the [static-eval](https://www.npmjs.org/package/static-eval) in addition to `__dirname` and `___filename`. \n\n## Upgrade from 1.x to 2.x\n\nThere was a signficant breaking change between 1.x and 2.x.  Note the following:\n\n### Specifying what should be urified\n\n`datauri` has been replaced with `urify`.\n\n#### 1.x\n\n```javascript\nvar datauri = require('datauri');\nvar data = datauri('path/to/file');\n```\n\n#### 2.x\n\n```javascript\nvar urify = require('urify');\nvar data = urify('path/to/file');\n```\n\n### Specifying Transform\n\nUse `urify/transform` instead of `urify`:\n\n#### 1.x\n\n```json\n  \"browserify\": {\n    \"transform\": [\n      \"urify\"\n    ]\n  }\n```\n\n#### 2.x\n\n```json\n  //2.x\n  \"browserify\": {\n    \"transform\": [\n      \"urify/transform\"\n    ]\n  }\n```\n\n\n## License\n\nMIT, see [LICENSE.md](http://github.com/mattdesl/urify/blob/master/LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattdesl%2Furify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattdesl%2Furify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattdesl%2Furify/lists"}