Ember CLI Build Config Editor

raw JSON →
0.5.1 verified Sat Apr 25 auth: no javascript maintenance

Utility for Ember blueprints to programmatically modify ember-cli-build.js. Current stable version 0.5.1. Maintained by srvance. Handles adding, editing, and querying flat configuration keys in the EmberApp build options. Uses JavaScript AST manipulation via esprima/ast-types. Alternative to manual string replacement or template-based approaches. Suitable for addon authors who need to inject or update build configuration during installation. Supports both Node.js CommonJS and usage within Ember CLI blueprints. Release cadence is irregular; latest release in 2019.

error TypeError: this.source.charCodeAt is not a function
cause Passed a Buffer instead of a string to the BuildConfigEditor constructor.
fix
fs.readFileSync('./ember-cli-build.js', 'utf-8')
error Cannot find module 'ember-cli-build-config-editor'
cause Package not installed or require path incorrect.
fix
npm install ember-cli-build-config-editor --save-dev
error build.edit is not a function
cause Using an older version where edit method may not exist; or importing incorrectly.
fix
Update to >=0.3.0 or check import: const BuildConfigEditor = require('ember-cli-build-config-editor');
gotcha Constructor expects a string, not a Buffer. Passing fs.readFileSync result without encoding causes 'this.source.charCodeAt is not a function'.
fix Specify encoding: fs.readFileSync('./ember-cli-build.js', 'utf-8')
breaking Version 5.0 introduced support for Ember addon configuration, changing internal behavior for addon config edits.
fix Review config editing for addons; may require using addonConfig property instead of edit for addon-specific keys.
deprecated Usage with ember install is discouraged as the package is not maintained actively; manual npm install recommended.
fix Use npm install --save-dev instead of ember install.
gotcha Only handles flat configurations; nested object config may be incorrectly merged or overwritten.
fix Ensure config keys are flat; use multiple edit calls for different top-level keys.
gotcha Supports only CommonJS require; ES modules import will fail at runtime.
fix Use require instead of import.
npm install ember-cli-build-config-editor
yarn add ember-cli-build-config-editor
pnpm add ember-cli-build-config-editor

Shows how to read, edit, and write Ember CLI build config using CommonJS require and the editor API.

const BuildConfigEditor = require('ember-cli-build-config-editor');
const fs = require('fs');

// Read the file as a string (not buffer)
const source = fs.readFileSync('./ember-cli-build.js', 'utf-8');

// Create editor instance
const build = new BuildConfigEditor(source);

// Add or update configuration for 'some-addon'
build.edit('some-addon', {
  booleanProperty: false,
  numericProperty: 17,
  stringProperty: 'wow'
});

// Write changes back
fs.writeFileSync('./ember-cli-build.js', build.code());

// Query existing config (returns parsed value or undefined)
const config = build.retrieve('some-addon');
console.log(config);