How to use the @kadira/storybook/dist/server/babel_config function in @kadira/storybook

To help you get started, we’ve selected a few @kadira/storybook examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storybookjs / storybook / src / cli.js View on Github external
.option('--extension [string]', 'File extension to use for storyshot files. Default is `.shot`')
  .option('--polyfills [string]', 'Add global polyfills')
  .option('--loaders [string]', 'Add loaders')
  .parse(process.argv);

const {
  configDir = './.storybook',
  polyfills: polyfillsPath = require.resolve('./default_config/polyfills.js'),
  loaders: loadersPath = require.resolve('./default_config/loaders.js'),
  grep,
  exclude,
} = program;

const configPath = path.resolve(configDir, 'config.js');

const babelConfig = loadBabelConfig(configDir);

// cacheDir is webpack babel loader specific. We don't run webpack.
delete babelConfig.cacheDirectory;

require('babel-register')(babelConfig);
require('babel-polyfill');

// load loaders
const loaders = require(path.resolve(loadersPath));

Object.keys(loaders).forEach(ext => {
  const loader = loaders[ext];
  require.extensions[`.${ext}`] = (m, filepath) => {
    m.exports = loader(filepath);
  };
})