Skip to content

simonihmig/ember-addon-config

Repository files navigation

ember-addon-config

Provide app users with an easy and opinionated way to configure (v2) addons.

Compatibility

  • Ember.js v4.8 or above
  • Embroider or ember-auto-import v2

Usage

For app users

If you have addons that make use of ember-addon-config, then create an config/addons.js file in your app if you have not done so already. For each addon, put the addon's package name as the key to the exported object and the its configuration as expected by the addon as the value:

// config/addons.js
'use strict';

module.exports = {
  'my-fancy-addon': {
    foo: 'bar',
  },
};

For addon authors

If you have a v2 addon that you want to make easily configuravle by your app users, then add @embroider/macros and ember-addon-config as dependencies of your addon.

If your users have configured your addon in their app's config/addons.js configuration file as explained above, you can retrieve that configuration in your addon code using getOwnConfig() imported from @embroider/macros (in JS/TS) or {{macroGetOwnConfig}} (in templates).

Given the macro capabilities, this also allows you introduce build-time conditionals, like only importing a library when a config option has been given. See the macros documentation for more information.

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

About

Provide an opinionated way to configure v2 addons

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages