import path from 'path' ; import type Config from 'webpack-chain' ; import type { ConfigManager } from '../../../config/configManager' ; export default ( configManager ) => ( config ) => { config . module . rule ( 'external-config' ) . test ( /[\\/]cli[\\/]lib[\\/]external[\\/]config.js$/ ) . use ( 'replace' ) . loader ( path . resolve ( __dirname , '../loaders/replaceContent' ) ) . options ( { code : `
  import { ConfigManager } from '@tramvai/cli/lib/config/configManager';

  const appConfig = ConfigManager.rehydrate(${ JSON . stringify ( configManager . dehydrate ( ) ) });
  const moduleConfig = appConfig;

  export { appConfig, moduleConfig };
  export default appConfig;
` , } ) . end ( ) . enforce ( 'post' ) ; } ;