generators/setup-env/utils.js
function getModifiedConfigModuleIndex(fileStr, snakedEnv, classedEnv) {
  // TODO [sthzg] we might want to rewrite the AST-mods in this function using a walker.

  const moduleFileAst = acorn.parse(fileStr, { module: true });

  // if required env was already created, just return the original string
  if (jp.paths(moduleFileAst, `$..[?(@.value=="./${classedEnv}" && @.type=="Literal")]`).length > 0) {
    return fileStr;
  }

  // insert require call for the new env
  const envImportAst = acorn.parse(`const ${snakedEnv} = require('./${classedEnv}');`);
  const insertAt = jp.paths(moduleFileAst, '$..[?(@.name=="require")]').pop()[2] + 1;
  moduleFileAst.body.splice(insertAt, 0, envImportAst);

  // add new env to module.exports
  const exportsAt = jp.paths(moduleFileAst, '$..[?(@.name=="exports")]').pop()[2];
  moduleFileAst.body[exportsAt].expression.right.properties.push(createExportNode(snakedEnv));

  return escodegen.generate(moduleFileAst, { format: { indent: { style: '  ' } } });
}
function getModifiedConfigModuleIndex(fileStr, snakedEnv, classedEnv) {
  // TODO [sthzg] we might want to rewrite the AST-mods in this function using a walker.

  const moduleFileAst = acorn.parse(fileStr, { module: true });

  // if required env was already created, just return the original string
  if (jp.paths(moduleFileAst, `$..[?(@.value=="./${classedEnv}" && @.type=="Literal")]`).length > 0) {
    return fileStr;
  }

  // insert require call for the new env
  const envImportAst = acorn.parse(`const ${snakedEnv} = require('./${classedEnv}');`);
  const insertAt = jp.paths(moduleFileAst, '$..[?(@.name=="require")]').pop()[2] + 1;
  moduleFileAst.body.splice(insertAt, 0, envImportAst);

  // add new env to module.exports
  const exportsAt = jp.paths(moduleFileAst, '$..[?(@.name=="exports")]').pop()[2];
  moduleFileAst.body[exportsAt].expression.right.properties.push(createExportNode(snakedEnv));

  return escodegen.generate(moduleFileAst, { format: { indent: { style: '  ' } } });
}
Returns updated index module requiring and exporting the newly created environment.

@param {string} fileStr
@param {string} snakedEnv
@param {string} classedEnv
@return {string} file contents of updated conf/webpack/index.js