Skip to content

Commit

Permalink
FIX babel_config plugin reading and creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaropinot committed May 30, 2017
1 parent a0f0d04 commit e28bf25
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/react/src/server/babel_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ export default function(configDir) {
}

const finalConfig = babelConfig || defaultConfig;
finalConfig.plugins = finalConfig.plugins || [];
finalConfig.plugins.push([
require.resolve('babel-plugin-react-docgen'),
{ DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES' },
]);
// Ensure plugins are defined or fallback to an array to avoid empty values.
const babelConfigPlugins = finalConfig.plugins || [];
const extraPlugins = [
[
require.resolve('babel-plugin-react-docgen'),
{
DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES',
},
],
];
// If `babelConfigPlugins` is not an `Array`, calling `concat` will inject it
// as a single value, if it is an `Array` it will be spreaded.
finalConfig.plugins = [].concat(babelConfigPlugins, extraPlugins);

return finalConfig;
}

0 comments on commit e28bf25

Please sign in to comment.