Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add react docgen info into React classes with the react-docgen babel plugin #557

Merged
merged 4 commits into from
Oct 21, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"autoprefixer": "^6.3.7",
"babel-core": "^6.11.4",
"babel-loader": "^6.2.4",
"babel-plugin-react-docgen": "^1.3.0",
"babel-preset-react-app": "^0.2.1",
"babel-runtime": "^6.9.2",
"case-sensitive-paths-webpack-plugin": "^1.1.2",
Expand Down
6 changes: 6 additions & 0 deletions src/server/babel_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export default function (configDir) {
path.resolve(babelConfig.extends);
}
}
const config = babelConfig || defaultConfig;
config.plugins = config.plugins || [];
config.plugins.push([
require.resolve('babel-plugin-react-docgen'),
{ DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES' },
]);

return babelConfig || defaultConfig;
}
3 changes: 3 additions & 0 deletions src/server/config/docgen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* globals window */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this filename as globals.js


window.STORYBOOK_REACT_CLASSES = {};
1 change: 1 addition & 0 deletions src/server/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function () {
preview: [
require.resolve('./polyfills'),
require.resolve('./error_enhancements'),
require.resolve('./docgen'),
`${require.resolve('webpack-hot-middleware/client')}?reload=true`,
],
},
Expand Down
1 change: 1 addition & 0 deletions src/server/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function () {
const entries = {
preview: [
require.resolve('./polyfills'),
require.resolve('./docgen'),
],
manager: [
require.resolve('./polyfills'),
Expand Down