npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jasonmit/ember-cli-dotenv

v2.0.1

Published

Expose .env variables in Ember applications

Downloads

246

Readme

Ember CLI Dotenv

Installation

ember install @jasonmit/ember-cli-dotenv

Upgrading to @jasonmit/[email protected]

  • npm uninstall ember-cli-dotenv
  • ember install @jasonmit/ember-cli-dotenv
  • open dotenv.js and ember-cli-build.js
  • Move/convert the dotEnv application options from ember-cli-build.js to the function declared within dotenv.js

What is Ember CLI Dotenv?

This addon allows you to write environment variables in a .env file and expose them to your Ember app through the built-in config/environment.js that you can import in your app. For example, you might be building an app with Dropbox and don’t want to check your key into the repo. Put a .env file in the root of your repository:

DROPBOX_KEY=YOURKEYGOESHERE

Next, configure dotenv.js.

// dotenv.js
module.exports = function(env) {
  return {
    clientAllowedKeys: ['DROPBOX_KEY']
  };
};

All keys in .env are currently injected into node’s process.env. These will be available in your config/environment.js file:

// config/environment.js
module.exports = function(environment) {
  return {
    MY_OTHER_KEY: process.env.MY_OTHER_KEY
  };
};

You can then use the node process environment variables in other ember-cli-addons, such as express middleware or other servers/tasks.

Security: environment variables in config/environment.js are never filtered unlike using .env and clientAllowedKeys. Remember to use the environment variable passed into your config function to filter out secrets for production usage. Never include sensitive variables in clientAllowedKeys, as these will be exposed publicly via ember's <meta name="app/config/environment"> tag.

then, you can access the environment variables anywhere in your app like you usually would.

import ENV from "my-app/config/environment";

console.log(ENV.DROPBOX_KEY); // logs YOURKEYGOESHERE

You can read more about dotenv files on their dotenv repository.

All the work is done by ember-cli and dotenv. Thanks ember-cli team and dotenv authors and maintainers! Thanks Brandon Keepers for the original dotenv ruby implementation.

Multiple Environments

Sometime people may want to use different .env file than the one in project root. This can be configured as below:

// dotenv.js
module.exports = function(env) {
  return {
    clientAllowedKeys: ['DROPBOX_KEY'],
    path: './path/to/.env'
  };
};

In addition, you may also customize for different environments:

// dotenv.js
module.exports = function(env) {
  return {
    clientAllowedKeys: ['DROPBOX_KEY'],
    path: `./path/to/.env-${env}`
  };
};

With the above, if you run ember build --environment production, the file ./path/to/.env.production will be used instead.

Compatibility

This addon supports the Ember 2.x series, but it is also backwards-compatible down to Ember-CLI 0.1.2 and Ember 1.7.0.

Other Resources

Development Installation

  • git clone this repository
  • npm install
  • bower install

Running

  • ember server
  • Visit your app at http://localhost:4200.

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.