ember-cli-dotenv icon indicating copy to clipboard operation
ember-cli-dotenv copied to clipboard

env vars not loaded in `.ember-cli.js`

Open emattias opened this issue 5 years ago • 1 comments

process.env doesnt have any of our dotenv vars in .ember-cli.js that we have in the rest of the ember app.

.ember-cli.js is executed before our config/dotenv.js.

We were able to work around it by doing this. But it would be nice to use ember-cli-dotenv like we do for all other env vars :) :

// .ember-cli.js

const dotEnv = require('dotenv');
const path = require('path');
const fs = require('fs');
const configDotEnv = require('./config/dotenv');

const { path: configPath } = configDotEnv(
  process.env.NODE_ENV || 'development'
);

const absoluteConfigPath = path.join(__dirname, configPath);
if (fs.existsSync(absoluteConfigPath)) {
  dotEnv.config({ path: absoluteConfigPath });
}

setEdition('octane');

let httpOrHttps = process.env.USE_SSL ? 'https' : 'http';
let port = process.env.USE_SSL ? 443 : 80;

module.exports = {
  disableAnalytics: true,
  port: 4200,
  liveReload: true,
  liveReloadPort: 1337,
  host: '0.0.0.0',
  ...
};

emattias avatar Mar 23 '20 14:03 emattias

@emattias I fear this is impossible to overcome by design as addons are not loaded at the time .ember-cli.js runs

SergeAstapov avatar Jan 04 '24 04:01 SergeAstapov