lib/core/src/server/utils/load-custom-babel-config.js
function loadFromPath(babelConfigPath) {
  let config;
  if (fs.existsSync(babelConfigPath)) {
    const content = fs.readFileSync(babelConfigPath, 'utf-8');
    try {
      config = JSON5.parse(content);
      config.babelrc = false;
      logger.info('=> Loading custom .babelrc');
    } catch (e) {
      logger.error(`=> Error parsing .babelrc file: ${e.message}`);
      throw e;
    }
  }

  if (!config) return null;

  // Remove react-hmre preset.
  // It causes issues with react-storybook.
  // We don't really need it.
  // Earlier, we fix this by running storybook in the production mode.
  // But, that hide some useful debug messages.
  if (config.presets) {
    removeReactHmre(config.presets);
  }

  if (config.env && config.env.development && config.env.development.presets) {
    removeReactHmre(config.env.development.presets);
  }

  return config;
}
function loadFromPath(babelConfigPath) {
  let config;
  if (fs.existsSync(babelConfigPath)) {
    const content = fs.readFileSync(babelConfigPath, 'utf-8');
    try {
      config = JSON5.parse(content);
      config.babelrc = false;
      logger.info('=> Loading custom .babelrc');
    } catch (e) {
      logger.error(`=> Error parsing .babelrc file: ${e.message}`);
      throw e;
    }
  }

  if (!config) return null;

  // Remove react-hmre preset.
  // It causes issues with react-storybook.
  // We don't really need it.
  // Earlier, we fix this by running storybook in the production mode.
  // But, that hide some useful debug messages.
  if (config.presets) {
    removeReactHmre(config.presets);
  }

  if (config.env && config.env.development && config.env.development.presets) {
    removeReactHmre(config.env.development.presets);
  }

  return config;
}
function loadFromPath ( babelConfigPath ) { let config ; if ( fs . existsSync ( babelConfigPath ) ) { const content = fs . readFileSync ( babelConfigPath , 'utf-8' ) ; try { config = JSON5 . parse ( content ) ; config . babelrc = false ; logger . info ( '=> Loading custom .babelrc' ) ; } catch ( e ) { logger . error ( ` ${ e . message } ` ) ; throw e ; } } if ( ! config ) return null ; // Remove react-hmre preset. // It causes issues with react-storybook. // We don't really need it. // Earlier, we fix this by running storybook in the production mode. // But, that hide some useful debug messages. if ( config . presets ) { removeReactHmre ( config . presets ) ; } if ( config . env && config . env . development && config . env . development . presets ) { removeReactHmre ( config . env . development . presets ) ; } return config ; }
Tries to load a .babelrc and returns the parsed object if successful
Tries to load a . babelrc and returns the parsed object if successful