{"id":13806422,"url":"https://github.com/ember-engines/ember-asset-loader","last_synced_at":"2025-10-15T23:02:51.417Z","repository":{"id":9955453,"uuid":"63908068","full_name":"ember-engines/ember-asset-loader","owner":"ember-engines","description":"Asset loading support for Ember applications","archived":false,"fork":false,"pushed_at":"2023-10-06T19:29:02.000Z","size":1183,"stargazers_count":33,"open_issues_count":20,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-03T16:18:50.271Z","etag":null,"topics":["broccoli","ember","ember-engines"],"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/ember-engines.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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}},"created_at":"2016-07-21T23:10:02.000Z","updated_at":"2024-03-22T00:25:53.000Z","dependencies_parsed_at":"2024-01-09T05:01:34.768Z","dependency_job_id":"73f91385-b3de-4535-bd71-7f2a4ba750d2","html_url":"https://github.com/ember-engines/ember-asset-loader","commit_stats":{"total_commits":189,"total_committers":28,"mean_commits":6.75,"dds":0.7407407407407407,"last_synced_commit":"6c489e4da70cb5b2d11aa9eceba2bc7539446f85"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-engines%2Fember-asset-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-engines%2Fember-asset-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-engines%2Fember-asset-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-engines%2Fember-asset-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ember-engines","download_url":"https://codeload.github.com/ember-engines/ember-asset-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248686058,"owners_count":21145413,"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":["broccoli","ember","ember-engines"],"created_at":"2024-08-04T01:01:11.541Z","updated_at":"2025-10-15T23:02:51.339Z","avatar_url":"https://github.com/ember-engines.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["End-user customization"],"readme":"# Ember Asset Loader\n\n[![Build Status](https://github.com/ember-engines/ember-asset-loader/workflows/CI/badge.svg)](https://github.com/ember-engines/ember-asset-loader/actions?query=workflow%3ACI)\n[![Code Climate](https://codeclimate.com/github/trentmwillis/ember-asset-loader/badges/gpa.svg)](https://codeclimate.com/github/trentmwillis/ember-asset-loader)\n\nProvides experimental support for the [Asset Manifest RFC](https://github.com/emberjs/rfcs/pull/153) and [Asset Loader Service RFC](https://github.com/emberjs/rfcs/pull/158).\n\n\n## Compatibility\n\n* Ember.js v3.24 or above\n* Ember CLI v3.24 or above\n* Node.js v14 or above\n\n## Usage\n\nEmber Asset Loader does three primary things:\n\n1. Provides a base class to easily generate an Asset Manifest,\n2. Provides an Ember service to use the generated manifest at runtime, and\n3. Initializes the above service with the above generated manifest.\n\n### Generating an Asset Manifest\n\nYou can generate an Asset Manifest by creating either a standalone or in-repo addon which extends from the\n`ManifestGenerator` base class:\n\n```js\nvar ManifestGenerator = require('ember-asset-loader/lib/manifest-generator');\nmodule.exports = ManifestGenerator.extend({\n  name: 'asset-generator-addon',\n  manifestOptions: {\n    bundlesLocation: 'engines-dist',\n    supportedTypes: [ 'js', 'css' ]\n  }\n});\n```\n\nThe `ManifestGenerator` will generate an asset manifest and merge it into your build tree during post-processing. It\ngenerates the manifest according to the options specified in `manifestOptions`:\n\n* The `bundlesLocation` option is a string that specifies which directory in the build tree contains the bundles to be\nplaced into the asset manifest. This defaults to `bundles`. Each bundle is a directory containing files that will be downloaded when the bundle is requested. You are responsible for getting the right files into those directories.\n\n* The `supportedTypes` option is an array that specifies which types of files should be included into the bundles for\nthe asset manifest. This defaults to `[ 'js', 'css' ]`.\n\n_Note: This class provides default `contentFor`, `postprocessTree`, and `postBuild` hooks so be sure that you call\n`_super` if you override one of those methods._\n\n### Why isn't a manifest generated by default?\n\nThis addon doesn't perform manifest generation just by virtue of being installed because there is no convention for\nbundling assets within Ember yet. Thus, to prevent introducing unintuitive or conflicting behavior, we provide no\ndefault generation and you must perform asset generation in your own addon using the base class provided by this addon.\n\nIf no manifest is generated, you'll get a warning at build time to ensure that you understand no manifest has been\ngenerated and thus you'll have to provide a manifest manually in order to use the Asset Loader Service. This warning can\nbe disabled via the `noManifest` option from the consuming application:\n\n```js\nvar app = new EmberApp(defaults, {\n  assetLoader: {\n    noManifest: true\n  }\n});\n```\n\n### Generating Custom URIs\n\nCustom URIs are often needed due to serving assets from CDNs or another server that does not share the same root\nlocation as your application. Instead of having to write a custom Broccoli plugin or other build-time transform, you can\nspecify a `generateURI` function as part of your application's options:\n\n```js\nvar app = new EmberApp(defaults, {\n  assetLoader: {\n    generateURI: function(filePath) {\n      return 'http://cdn.io/' + filePath;\n    }\n  }\n});\n```\n\nThe function receives the `filePath` for each asset and must return a string.\n\n### Ignore Files\n\nTo ignore specific files during the manifest generation, use `filesToIgnore`.\nBoth string and regex patterns are accepted.\n\n\n```js\nvar app = new EmberApp(defaults, {\n  assetLoader: {\n    filesToIgnore: [/foo-engine/**/engine-vendor.js$/, 'vendor.js']\n  }\n});\n```\n\n### Using With `broccoli-asset-rev`\n\nYou need to make sure that `broccoli-asset-rev` runs after your ManifestGenerator addon runs. Here is an example of how to do that:\n\n1. Create an in-repo-addon: `ember generate in-repo-addon asset-generator-addon`\n\n2. Make it generate the manifest by editing `lib/asset-generator-addon/index.js` as described under \"Generating an Asset Manifest\" above.\n\n3. Edit `lib/asset-generator-addon/package.json` to configure the addon to run after `broccoli-asset-rev`\n\n```json\n{\n  \"name\": \"asset-generator-addon\",\n  \"keywords\": [\n    \"ember-addon\"\n  ],\n  \"ember-addon\": {\n    \"after\": \"broccoli-asset-rev\"\n  }\n}\n```\n\n## Usage with FastBoot / Server-Side Rendering Solutions\n\nUsing lazily loaded assets with a server-side rendering solution, such as FastBoot, is often desirable to maximize\nperformance for your consumers. However, lazy loading assets on your server is not the same as on the client and\ncan actually have negative performance impact. Due to that, the recommendation is to pre-load all your assets in the\nserver.\n\nAdditionally, at build time we will generate an `assets/node-asset-manifest.js` file that should be included in your SSR\nenvironment to ensure that your application can correctly access asset information.\n\nSee the [\"How to handle running in Node\"](https://github.com/ember-engines/ember-asset-loader/issues/21) issue for more\ninformation.\n\n## Pre-loading Assets During Testing\n\nFor test environments it is often useful to load all of the assets in a manifest upfront. You can do this by using the\n`preloadAssets` helper, like so:\n\n```js\n// tests/test-helper.js\nimport preloadAssets from 'ember-asset-loader/test-support/preload-assets';\nimport manifest from 'app/config/asset-manifest';\n\npreloadAssets(manifest);\n```\n\n### Resetting Test State\n\nWhen testing applications with lazy assets, it is important to reset the state of those assets in between tests. To do\nthis, Ember Asset Loader provides two helpers: `cacheLoadedAssetState()` and `resetLoadedAssetState()`.\n\n```js\n// tests/test-helper.js\nimport preloadAssets from 'ember-asset-loader/test-support/preload-assets';\nimport { cacheLoadedAssetState, resetLoadedAssetState } from 'ember-asset-loader/test-support/loaded-asset-state';\nimport manifest from 'app/config/asset-manifest';\n\ncacheLoadedAssetState();\npreloadAssets(manifest).then(() =\u003e {\n  resetLoadedAssetState(); // Undoes the previous load!\n});\n```\n\nIt is important to note that `resetLoadedAssetState` can only remove additional scripts, stylesheets, and modules loaded\nsince `cacheLoadedAssetState` was called. If any of the loaded assets modified global state, we'll be unable to restore\nthat state. Therefore, it is important to keep your lazy assets encapsulated and make sure they don't modified any state\nalready in the browser.\n\n_Note: If you use QUnit, it may be worthwhile to turn on the [`noglobals` config option](https://api.qunitjs.com/QUnit.config/),\nto help catch mutated global state._\n\n## Installation\n\n* `git clone https://github.com/ember-engines/ember-asset-loader`\n* `cd ember-asset-loader`\n* `npm install`\n* `bower install`\n\n## Running\n\n* `ember serve`\n* Visit the tests at [http://localhost:4200/tests](http://localhost:4200/tests).\n\n## Running Tests\n\nOne of three options:\n\n* `npm test` (Runs `ember try:each` to test your addon against multiple Ember versions)\n* `ember test`\n* `ember test --server`\n\n## Building\n\n* `ember build`\n\nFor more information on using ember-cli, visit [http://ember-cli.com/](http://ember-cli.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-engines%2Fember-asset-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fember-engines%2Fember-asset-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-engines%2Fember-asset-loader/lists"}