First, you need to initialize the API for your style guide config.
Using a JavaScript object:
const styleguidist = require('react-styleguidist');
const styleguide = styleguidist({
components: './lib/components/**/*.js',
webpackConfig: {
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.css$/,
loader: 'style-loader!css-loader?modules',
},
],
},
},
});Using a config file:
const styleguidist = require('react-styleguidist');
const styleguide = styleguidist(require('../styleguide.config.js'));Or auto searching a config file:
const styleguidist = require('react-styleguidist');
const styleguide = styleguidist();See all available config options.
callback(err, config, stats)(Function): A callback to be invoked when style guide is built:err(Object): error details.config(Object): normalized style guide config.stats(Object): webpack build stats.
(Compiler): webpack Compiler instance.
const styleguidist = require('react-styleguidist');
styleguidist(require('../styleguide.config.js')).build((err, config) => {
if (err) {
console.log(err);
}
else {
console.log('Style guide published to', config.styleguideDir);
}
});callback(err, config)(Function): A callback to be invoked when style guide is built:err(Object): error details.config(Object): normalized style guide config.
(Compiler): webpack Compiler instance.
const styleguidist = require('react-styleguidist');
styleguidist(require('../styleguide.config.js')).server((err, config) => {
if (err) {
console.log(err);
}
else {
console.log('Listening at http://' + config.serverHost + ':' + config.serverPort);
}
});- [
env='production'] (String):productionordevelopment.
(Object): webpack config.
// webpack.config.js
module.exports = [
{
// User webpack config
},
require('react-styleguidist')().makeWebpackConfig(),
];