Created
February 23, 2018 23:37
-
-
Save maddrag0n/fe8c8b2d694f28bc30d4605357b204ac to your computer and use it in GitHub Desktop.
react-styleguidist setup for material-ui, react-bootstrap, babel module-resolver, TapEventPlugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
module.exports = { | |
assetsDir: 'static/', | |
components: 'app/{components,containers}/**/*.jsx', | |
getComponentPathLine(componentPath) { | |
const name = path.basename(componentPath, '.jsx') | |
const dir = path.dirname(componentPath).replace('app/', ''); | |
return `import ${name} from '${dir}/${name}';` | |
}, | |
getExampleFilename(componentPath) { | |
return componentPath.replace(/\.jsx?$/, '.examples.md'); | |
}, | |
sections: [ | |
{ | |
name: 'UI Components', | |
components: 'app/components/**/*.jsx', | |
}, | |
{ | |
name: 'UI Containers', | |
components: 'app/containers/**/*.jsx', | |
}, | |
], | |
showUsage: true, | |
styleguideComponents: { | |
Wrapper: path.join(__dirname, 'app/styleguidist/StyleguidistMuiWrapper'), | |
}, | |
skipComponentsWithoutExample: true, | |
webpackConfig: { | |
module: { | |
loaders: [ | |
{ | |
test: /\.(js|jsx)?$/, | |
exclude: [/node_modules/], | |
loader: 'babel-loader', | |
query: { | |
cacheDirectory: true, | |
babelrc: true, | |
}, | |
}, | |
] | |
}, | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import React from 'react'; | |
import type { Element as ReactElement } from 'react'; | |
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; | |
import getMuiTheme from 'material-ui/styles/getMuiTheme'; | |
import RsgWrapper from 'react-styleguidist/lib/rsg-components/Wrapper'; | |
import injectTapEventPlugin from 'react-tap-event-plugin'; | |
import $ from 'jquery'; | |
injectTapEventPlugin(); | |
const muiTheme = getMuiTheme({}); | |
const RsgMuiWrapper = ({ children, ...rest }: { children: ReactElement<*>, }) => ( | |
<RsgWrapper {...rest}> | |
<MuiThemeProvider muiTheme={muiTheme}> | |
{children} | |
</MuiThemeProvider> | |
</RsgWrapper> | |
); | |
export default RsgMuiWrapper; | |
// bootstrap css for react-bootstrap | |
if (typeof window !== 'undefined') { | |
$('<link data-description="bootstrap styles" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />') | |
.appendTo('head'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment