{"id":15538906,"url":"https://github.com/buschtoens/ember-cli-resolve-asset","last_synced_at":"2025-04-23T15:42:14.825Z","repository":{"id":47454244,"uuid":"169615380","full_name":"buschtoens/ember-cli-resolve-asset","owner":"buschtoens","description":"Resolves asset paths to their fingerprinted counterpart. Useful for interpolated paths.","archived":false,"fork":false,"pushed_at":"2023-12-15T20:34:41.000Z","size":638,"stargazers_count":10,"open_issues_count":23,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-09T12:42:04.655Z","etag":null,"topics":["ember-addon","ember-cli","ember-cli-addon","emberjs"],"latest_commit_sha":null,"homepage":null,"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/buschtoens.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-07T17:49:43.000Z","updated_at":"2020-11-15T11:33:44.000Z","dependencies_parsed_at":"2024-06-19T16:23:57.330Z","dependency_job_id":"6cd727de-e876-47bd-a808-fabaebc0e3eb","html_url":"https://github.com/buschtoens/ember-cli-resolve-asset","commit_stats":{"total_commits":178,"total_committers":4,"mean_commits":44.5,"dds":0.1853932584269663,"last_synced_commit":"7c9652dab12f01eaa274d666afd30d64b91d3de6"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fember-cli-resolve-asset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fember-cli-resolve-asset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fember-cli-resolve-asset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fember-cli-resolve-asset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buschtoens","download_url":"https://codeload.github.com/buschtoens/ember-cli-resolve-asset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250462401,"owners_count":21434575,"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":["ember-addon","ember-cli","ember-cli-addon","emberjs"],"created_at":"2024-10-02T12:07:43.592Z","updated_at":"2025-04-23T15:42:14.787Z","avatar_url":"https://github.com/buschtoens.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-cli-resolve-asset\n\n[![Build Status](https://travis-ci.org/buschtoens/ember-cli-resolve-asset.svg)](https://travis-ci.org/buschtoens/ember-cli-resolve-asset)\n[![npm version](https://badge.fury.io/js/ember-cli-resolve-asset.svg)](http://badge.fury.io/js/ember-cli-resolve-asset)\n[![Download Total](https://img.shields.io/npm/dt/ember-cli-resolve-asset.svg)](http://badge.fury.io/js/ember-cli-resolve-asset)\n[![Ember Observer Score](https://emberobserver.com/badges/ember-cli-resolve-asset.svg)](https://emberobserver.com/addons/ember-cli-resolve-asset)  \n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![dependencies](https://img.shields.io/david/buschtoens/ember-cli-resolve-asset.svg)](https://david-dm.org/buschtoens/ember-cli-resolve-asset)\n[![devDependencies](https://img.shields.io/david/dev/buschtoens/ember-cli-resolve-asset.svg)](https://david-dm.org/buschtoens/ember-cli-resolve-asset)\n\nImperatively resolves assets fingerprinted by\n[**`broccoli-asset-rev`**][broccoli-asset-rev], which allows you to even resolve\n_interpolated_ paths.\n\n## Installation\n\n```\nember install ember-cli-resolve-asset\n```\n\nIf you want to use this in one of your addons, the consuming host application\nwill also need to install `ember-cli-resolve-asset`. If this not a case, a\nhelpful build error will be shown.\n\n### Setup\n\nThe following configuration in your `ember-cli-build.js` is required for this\naddon to work correctly.\n\n```js\nconst app = new EmberAddon(defaults, {\n  fingerprint: {\n    enabled: true, // If false, this addon is disabled also.\n    generateAssetMap: true, // Required.\n    fingerprintAssetMap: true // Recommended to prevent caching issues.\n  },\n\n  'ember-fetch': {\n    preferNative: true // Recommended to enable faster preloading for browsers that support it.\n  }\n});\n```\n\n- [`broccoli-asset-rev` options](https://github.com/rickharrison/broccoli-asset-rev#options)\n- [`ember-fetch` options](https://github.com/ember-cli/ember-fetch#allow-native-fetch)\n\n## Usage\n\n### Utils\n\n#### `resolveAsset`\n\n**`async resolveAsset(path: string, withoutPrepend = false): Promise\u003cstring\u003e`**\n\nAsynchronously resolves the given `path` from the asset map.\n\nIf the asset map is not loaded yet, this function will wait for it.\nIf loading the asset map fails, the returned `Promise` will reject.\nIf the path is not listed in the asset map, the returned `Promise` will reject.\n\n```ts\nimport Route from '@ember/routing/route';\nimport { inject as service } from '@ember/service';\nimport fetch from 'fetch';\nimport resolveAsset from 'ember-cli-resolve-asset';\n\nexport default class ApplicationRoute extends Route {\n  @service intl;\n  @service language;\n\n  async beforeModel() {\n    const preferredLanguage = this.language.getPreferredLanguage();\n    const translationsPath = await resolveAsset(\n      `translations/${preferredLanguage}.json`\n    );\n    const translations = await fetch(translationsPath);\n\n    this.intl.addTranslations(preferredLanguage, await translations.json());\n    this.intl.setLocale(preferredLanguage);\n  }\n}\n```\n\n#### `resolveAssetSync`\n\n**`resolveAssetSync(path: string, withoutPrepend = false): string`**\n\nSynchronous version of [`resolveAsset`](#resolveAsset).\n\nSynchronously resolves the given `path` from the asset map.\n\nIf the asset map is not loaded yet, this function will throw.\nIf the path is not listed in the asset map, this function will throw.\n\nUsage of this function is discouraged in favor of `resolveAsset`. Only use this\nfunction, if using the async version is not feasible and if you can guarantee,\nthat [`load`](#load) ran to completion beforehand.\n\n```ts\nimport Route from '@ember/routing/route';\nimport { inject as service } from '@ember/service';\nimport fetch from 'fetch';\nimport {\n  resolveAssetSync,\n  load as loadAssetMap\n} from 'ember-cli-resolve-asset';\n\nexport default class ApplicationRoute extends Route {\n  @service intl;\n  @service language;\n\n  async beforeModel() {\n    await loadAssetMap();\n\n    const preferredLanguage = this.language.getPreferredLanguage();\n    const translationsPath = resolveAssetSync(\n      `translations/${preferredLanguage}.json`\n    );\n    const translations = await fetch(translationsPath);\n\n    this.intl.addTranslations(preferredLanguage, await translations.json());\n    this.intl.setLocale(preferredLanguage);\n  }\n}\n```\n\n#### `load`\n\n**`async load(): Promise\u003cvoid\u003e`**\n\nThis function returns a `Promise` that resolves once the asset map was loaded\nsuccessfully. Repeatedly calling this function returns the same `Promise`. After\nthis `Promise` has resolved, you can use\n[`resolveAssetSync`](#resolveAssetSync).\n\nThis function is called automatically by an initializer, to start the loading of\nthe asset map as soon as possible. This means there is no direct need for you to\ncall this function yourself, unless you want to await the asset map explicitly.\n\n## Related Projects\n\n- [**`broccoli-asset-rev`**][broccoli-asset-rev]: The ember-cli addon that\n  performs the fingerprinting and generates the asset map.\n- [**`ember-fetch`**][ember-fetch]: Used by this addon to asynchronously load\n  the asset map.\n- [**`ember-cli-ifa`**][ember-cli-ifa]: The original inspiration for this addon.\n  I was dissatisfied with the technical implementation, the bugs it caused and\n  current state of maintenance, which is why I created this addon instead.\n\n[broccoli-asset-rev]: https://github.com/rickharrison/broccoli-asset-rev\n[ember-fetch]: https://github.com/ember-cli/ember-fetch\n[ember-cli-ifa]: https://github.com/RuslanZavacky/ember-cli-ifa\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuschtoens%2Fember-cli-resolve-asset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuschtoens%2Fember-cli-resolve-asset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuschtoens%2Fember-cli-resolve-asset/lists"}